This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Exits | |
| include Garb::Resource | |
| metrics :exits, :exit_rate | |
| dimensions :request_uri | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Exits.results(profile, :limit => 10, | |
| :offset => 20, | |
| :start_date => (Date.today - 30), | |
| :end_date => Date.today) | |
| # With Filtering and Sorting | |
| Exits.results(profile) do | |
| filter :request_uri.contains => 'fun', :exits.gte => 1000 | |
| sort :exit_rate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| report = Garb::Report.new(profile) | |
| report.metrics :exits, :exit_rate | |
| report.dimensions :request_uri | |
| # With Filtering and Sort | |
| report.filter :request_uri.contains => 'fun', :exits.gte => 1000 | |
| report.sort :exit_rate.desc | |
| # Getting Results |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Search | |
| include DataMapper::Resource | |
| property :id, Serial | |
| end | |
| class Result | |
| include DataMapper::Resource | |
| property :id, Serial | |
| belongs_to :search | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # | |
| # A one file test to show ... | |
| require 'rubygems' | |
| require 'dm-core' | |
| # setup the logger | |
| DataMapper::Logger.new(STDOUT, :debug) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class GameMode | |
| include DataMapper::Resource | |
| property :id, Serial | |
| property :title, String | |
| property :description, Text | |
| property :max_players, Integer | |
| has n :games, :through => Resource | |
| has n, :types, :through => Resource |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT "items"."id", "items"."item_code", "items"."item_number", "items"."description", "items"."size", "items"."retail", "items"."vintage" | |
| FROM "items" | |
| INNER JOIN "sale_items" ON "items"."id" = "sale_items"."item_id" | |
| INNER JOIN "sales" ON "sale_items"."sale_id" = "sales"."id" AND "sale_items"."sale_sale_time" = "sales"."sale_time" | |
| WHERE "sale_items"."sale_id" IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 58) | |
| GROUP BY "items"."id", "items"."item_code", "items"."item_number", "items"."description", "items"."size", "items"."retail", "items"."vintage" | |
| ORDER BY "items"."id" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| gem 'dm-core', '0.10.0' | |
| require 'dm-core' | |
| DataMapper.setup(:default, 'postgres://tpitale@localhost/test_through') | |
| # DataObjects::Postgres.logger = DataObjects::Logger.new(STDOUT, :debug) | |
| class Retailer | |
| include DataMapper::Resource |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| INSERT INTO "sales" ("sale_time", "retailer_id", "user_id") VALUES ('2009-05-14 12:44:46.474-04', 1, 1364) RETURNING "id" | |
| Wed, 10 Jun 2009 20:22:09 GMT ~ debug ~ (0.006935) SELECT "id", "retail", "points", "sale_id", "item_id" FROM "sale_items" WHERE "sale_id" IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 17 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| > ratings = (1..21).to_a | |
| => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21] | |
| > ratings.map { ratings.slice!(0,2) } | |
| => [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]] | |
| > ratings | |
| => [15, 16, 17, 18, 19, 20, 21] | |
| # why are those left over? |
OlderNewer