twoixter / trackoid Goto Github PK
View Code? Open in Web Editor NEWTrackoid is an easy scalable analytics tracker using MongoDB and Mongoid
License: MIT License
Trackoid is an easy scalable analytics tracker using MongoDB and Mongoid
License: MIT License
trackoid git:master ❯ rake spec ✹ ✭
rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)
/Users/gk/.rvm/rubies/ruby-1.9.2-p290/bin/ruby -S bundle exec rspec spec/aggregates_spec.rb spec/ext/range_spec.rb spec/ext/time_spec.rb spec/reader_extender_spec.rb spec/readers_spec.rb spec/timezone_spec.rb spec/trackoid_spec.rb
**Notice: C extension not loaded. This is required for optimum MongoDB Ruby driver performance.
You can install the extension as follows:
gem install bson_ext
If you continue to receive this message after installing, make sure that the
bson_ext gem is in your load path and that the bson_ext and mongo gems are of the same version.
Mongoid::Tracking::Aggregates
should define a class model named after the original model
should define a class model named after the original second model
should create a has_many relationship in the original model
should have the aggregates klass in a class/instance var
should create a hash in the class with all aggregate fields
should create an array in the class with all aggregate fields even when monkey patching
the aggregated class should have the same tracking fields as the parent class
should raise error if we try to add an aggregation token twice
should raise error if we try to use 'hours' as aggregate
should have Mongoid accessors defined (FAILED - 1)
should indicate this is an aggregated traking object with aggregated?
should indicate this is an aggregated class with aggregated?
should raise error if already defined class with the same aggregated klass name
should NOT raise error if the already defined class is our aggregated model
should raise error although the already defined class includes tracking
testing different object class for aggregation key
should correctly save all aggregation keys as strings (inc) (FAILED - 2)
should correctly save all aggregation keys as strings (set) (FAILED - 3)
when tracking a model with aggregation data
calling an aggregation scope should return the appropiate class
should increment visits for all aggregated instances (FAILED - 4)
should increment visits for specific aggregation keys (FAILED - 5)
should NOT increment visits for different aggregation keys
should have 1 visits today (FAILED - 6)
should have 0 visits yesterday (FAILED - 7)
should have 1 visits last 7 days (FAILED - 8)
should work also for arbitrary days (FAILED - 9)
should work adding 1 visit with different aggregation data (FAILED - 10)
should return only values when specifying the aggregation key (FAILED - 11)
should work also with set (FAILED - 12)
let's check what happens when sorting the best browser... (FAILED - 13)
should work without aggregation information (FAILED - 14)
When using reset method for aggregates
should have the correct values when using a value (FAILED - 15)
should delete the values when using nil (FAILED - 16)
erase method sould also work (FAILED - 17)
should reset the correct tracking fields (FAILED - 18)
should erase the correct tracking fields (FAILED - 19)
Testing all accessors
should return the correct values for .all_values (FAILED - 20)
should return the all values for every aggregate (FAILED - 21)
should return the correct first_date for every aggregate (FAILED - 22)
should return the correct last_date for every aggregate (FAILED - 23)
should return the first value for aggregates (FAILED - 24)
should return the last value for aggregates (FAILED - 25)
Range
using the diff method
should work for normal ranges
should work for Time ranges (DAYS)
should work for Time ranges (HOURS)
should also work when using helper methods
should behave like normal ranges for 1 element
should keep Time UTC and DST properties
using the map method
should work for normal ranges (using enumerator)
should work for normal ranges (using block)
should work for Time ranges
should work for empty excluding Time ranges
should return an array if no block given
should also work using helper methods
Time
when working with UTC dates
should return the correct timestamp
should return the correct hours
should convert back with timestamps and hours
should work also on ranges (dates)
should work also on ranges (hours)
should iterate for a day and return the correct UTC keys
should iterate for a day and return the correct UTC keys (Helper methods)
when working with TZ dates (Europe)
should return the correct timestamp
should return the correct hours
should convert back with timestamps and hours
when working with TZ dates (America)
should return the correct timestamp
should return the correct hours
should convert back with timestamps and hours
should iterate for a day and return the correct UTC keys
should iterate for a day and return the correct UTC keys (Helper methods)
Mongoid::Tracking::ReaderExtender
should behave like a number
should behave like a float
to_f should return a Float (for ActionView::Template compat.)
as_json should not return a 'total' and a 'hours' member
hourly as_json should return an array
should be able to add additional data to it
should be able to sum two ReadersExtenders
should be able to sum more than two ReadersExtenders
Testing Readers with a model
should return the correct values for a range using 'on' (FAILED - 26)
should return the correct values for .all_values (FAILED - 27)
should return the correct values for .all_values (Take II) (FAILED - 28)
Testing Readers with an empty model
should return nil for .first_date
should return nil for .last_date
should return nil for .first_value
should return nil for .last_value
should return nil for .all_values
Mongoid::Tracking
Testing the system TZ for Europe/Madrid
should convert dates to UTC
should create dates in UTC
should create dates in local time
should detect daylight saving for local times
timestamps should be offset by the utc_offset
timestamps should be offset by the utc_offset even when daylight saving is on
Testing the system TZ for America/San Francisco
should convert dates to UTC
should create dates in UTC
should create dates in local time
should detect daylight saving for local times
timestamps should be offset by the utc_offset
timestamps should be offset by the utc_offset even when daylight saving is on
Testing the RAILS TZ capabilities
should support time zone changing
should correctly handle UTC offseted dates
Testing TZ data with real models
should correctly handle hours for my TimeZone (FAILED - 29)
should correctly handle hours for UTC (FAILED - 30)
Hours in Europe/Madrid (Winter time) should be shifted by 1 hour from UTC (FAILED - 31)
Hours in Europe/Madrid (Summer time) should be shifted by 2 hour from UTC (FAILED - 32)
Hours in America/Los_Angeles (Winter time) should be shifted by -8 hours from UTC (FAILED - 33)
Hours in America/Los_Angeles (Summer time) should be shifted by -7 hours from UTC (FAILED - 34)
A value set at 10am on Madrid should appear as 01am on San Francisco (FAILED - 35)
A value set at 10am on Madrid should appear as 01am on San Francisco (Using offsets) (FAILED - 36)
A value set now on Madrid should appear shifted 9 hours on San Francisco (Using offsets) (FAILED - 37)
Mongoid::Tracking
should expose the same version as the VERSION file
should raise error when used in a class not of class Mongoid::Document
should not raise error when used in a class of class Mongoid::Document
when creating a new field with stats
should deny access to the underlying mongoid field
should create a method for accesing the stats
should NOT create an index for the stats field
should respond 'false' to field_changed? method
should create a method for accesing the stats of the proper class
should create an array in the class with all tracking fields
should create an array in the class with all tracking fields even when monkey patching
should not update stats when new record
shold create an empty hash as the internal representation
should give 0 for today stats
should give 0 for last 7 days stats
should give today stats for last 0 days stats
should not be aggregated
when using a model in the database
should increment visits stats for today (FAILED - 38)
should increment another visits stats for today for a total of 2 (FAILED - 39)
should also work for yesterday (FAILED - 40)
should also work for yesterday if adding another visit (for a total of 2) (FAILED - 41)
then, the visits of today + yesterday must be the same (FAILED - 42)
should have 4 visits for this test (FAILED - 43)
should correctly handle the 7 days (FAILED - 44)
string dates should work (FAILED - 45)
should give the first date with first_date (FAILED - 46)
should give the last date with last_date (FAILED - 47)
should give the first value (FAILED - 48)
should give the last value (FAILED - 49)
testing reader operations without reloading models
'set' operator must work (FAILED - 50)
'set' operator must work on arbitrary days (FAILED - 51)
'add' operator must work (FAILED - 52)
'add' operator must work on arbitrary days (FAILED - 53)
on() accessor must work on dates as String (FAILED - 54)
on() accessor must work on Date descendants (FAILED - 55)
on() accessor must work on dates as Ranges (FAILED - 56)
regression test for github issues
should not raise undefined method [] for nil:NilClass when adding a new track into an existing object (FAILED - 57)
Failures:
1) Mongoid::Tracking::Aggregates should have Mongoid accessors defined
Failure/Error: tm.send(tm.class.send(:internal_accessor_name, "browsers")).class.should == Mongoid::Criteria
expected: Mongoid::Criteria
got: Mongoid::Relations::Targets::Enumerable (using ==)
Diff:
@@ -1,2 +1,2 @@
-Mongoid::Criteria
+Mongoid::Relations::Targets::Enumerable
# ./spec/aggregates_spec.rb:99:in `block (2 levels) in <top (required)>'
2) Mongoid::Tracking::Aggregates testing different object class for aggregation key should correctly save all aggregation keys as strings (inc)
Failure/Error: @mock.something("test").inc
NoMethodError:
undefined method `_selector' for #<SecondTestModel:0x007fb3926f28c0>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./lib/trackoid/tracker.rb:68:in `inc'
# ./spec/aggregates_spec.rb:173:in `block (3 levels) in <top (required)>'
3) Mongoid::Tracking::Aggregates testing different object class for aggregation key should correctly save all aggregation keys as strings (set)
Failure/Error: @mock.something("test").set(5)
NoMethodError:
undefined method `_selector' for #<SecondTestModel:0x007fb3926d7638>
# ./lib/trackoid/tracker.rb:79:in `set'
# ./spec/aggregates_spec.rb:181:in `block (3 levels) in <top (required)>'
4) Mongoid::Tracking::Aggregates when tracking a model with aggregation data should increment visits for all aggregated instances
Failure/Error: @mock.visits("Mozilla Firefox").inc
NoMethodError:
undefined method `_selector' for #<TestModel:0x007fb392694450>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./lib/trackoid/tracker.rb:68:in `inc'
# ./spec/aggregates_spec.rb:205:in `block (3 levels) in <top (required)>'
5) Mongoid::Tracking::Aggregates when tracking a model with aggregation data should increment visits for specific aggregation keys
Failure/Error: @mock.browsers("mozilla").size.should == 1
expected: 1
got: 0 (using ==)
# ./spec/aggregates_spec.rb:212:in `block (3 levels) in <top (required)>'
6) Mongoid::Tracking::Aggregates when tracking a model with aggregation data should have 1 visits today
Failure/Error: @mock.visits.browsers.today.should == [["mozilla", 1]]
expected: [["mozilla", 1]]
got: [] (using ==)
Diff:
@@ -1,2 +1,2 @@
-[["mozilla", 1]]
+[]
# ./spec/aggregates_spec.rb:224:in `block (3 levels) in <top (required)>'
7) Mongoid::Tracking::Aggregates when tracking a model with aggregation data should have 0 visits yesterday
Failure/Error: @mock.visits.browsers.yesterday.should == [["mozilla", 0]]
expected: [["mozilla", 0]]
got: [] (using ==)
Diff:
@@ -1,2 +1,2 @@
-[["mozilla", 0]]
+[]
# ./spec/aggregates_spec.rb:229:in `block (3 levels) in <top (required)>'
8) Mongoid::Tracking::Aggregates when tracking a model with aggregation data should have 1 visits last 7 days
Failure/Error: @mock.visits.browsers.last_days(7).should == [["mozilla", [0, 0, 0, 0, 0, 0, 1]]]
expected: [["mozilla", [0, 0, 0, 0, 0, 0, 1]]]
got: [] (using ==)
Diff:
@@ -1,2 +1,2 @@
-[["mozilla", [0, 0, 0, 0, 0, 0, 1]]]
+[]
# ./spec/aggregates_spec.rb:234:in `block (3 levels) in <top (required)>'
9) Mongoid::Tracking::Aggregates when tracking a model with aggregation data should work also for arbitrary days
Failure/Error: @mock.visits.browsers.last_days(15).should == [["mozilla", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]]
expected: [["mozilla", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]]
got: [] (using ==)
Diff:
@@ -1,2 +1,2 @@
-[["mozilla", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]]
+[]
# ./spec/aggregates_spec.rb:239:in `block (3 levels) in <top (required)>'
10) Mongoid::Tracking::Aggregates when tracking a model with aggregation data should work adding 1 visit with different aggregation data
Failure/Error: @mock.visits("Google Chrome").inc
NoMethodError:
undefined method `_selector' for #<TestModel:0x007fb39252e408>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./lib/trackoid/tracker.rb:68:in `inc'
# ./spec/aggregates_spec.rb:244:in `block (3 levels) in <top (required)>'
11) Mongoid::Tracking::Aggregates when tracking a model with aggregation data should return only values when specifying the aggregation key
Failure/Error: @mock.visits.browsers("mozilla").today.should == 1
expected: 1
got: nil (using ==)
# ./spec/aggregates_spec.rb:253:in `block (3 levels) in <top (required)>'
12) Mongoid::Tracking::Aggregates when tracking a model with aggregation data should work also with set
Failure/Error: @mock.visits("Google Chrome").set(5)
NoMethodError:
undefined method `_selector' for #<TestModel:0x007fb39250fa58>
# ./lib/trackoid/tracker.rb:79:in `set'
# ./spec/aggregates_spec.rb:257:in `block (3 levels) in <top (required)>'
13) Mongoid::Tracking::Aggregates when tracking a model with aggregation data let's check what happens when sorting the best browser...
Failure/Error: @mock.visits("Google Chrome").inc
NoMethodError:
undefined method `_selector' for #<TestModel:0x007fb3924eedf8>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./lib/trackoid/tracker.rb:68:in `inc'
# ./spec/aggregates_spec.rb:264:in `block (3 levels) in <top (required)>'
14) Mongoid::Tracking::Aggregates when tracking a model with aggregation data should work without aggregation information
Failure/Error: @mock.visits.inc
NoMethodError:
undefined method `_selector' for #<TestModel:0x007fb3924c2ac8>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./lib/trackoid/tracker.rb:68:in `inc'
# ./spec/aggregates_spec.rb:270:in `block (3 levels) in <top (required)>'
15) Mongoid::Tracking::Aggregates When using reset method for aggregates should have the correct values when using a value
Failure/Error: @mock.visits("Mozilla Firefox").set(1, "2010-07-11")
NoMethodError:
undefined method `_selector' for #<TestModel:0x007fb3924661d8>
# ./lib/trackoid/tracker.rb:79:in `set'
# ./spec/aggregates_spec.rb:289:in `block (3 levels) in <top (required)>'
16) Mongoid::Tracking::Aggregates When using reset method for aggregates should delete the values when using nil
Failure/Error: @mock.visits("Mozilla Firefox").set(1, "2010-07-11")
NoMethodError:
undefined method `_selector' for #<TestModel:0x007fb3923a9218>
# ./lib/trackoid/tracker.rb:79:in `set'
# ./spec/aggregates_spec.rb:289:in `block (3 levels) in <top (required)>'
17) Mongoid::Tracking::Aggregates When using reset method for aggregates erase method sould also work
Failure/Error: @mock.visits("Mozilla Firefox").set(1, "2010-07-11")
NoMethodError:
undefined method `_selector' for #<TestModel:0x007fb392366300>
# ./lib/trackoid/tracker.rb:79:in `set'
# ./spec/aggregates_spec.rb:289:in `block (3 levels) in <top (required)>'
18) Mongoid::Tracking::Aggregates When using reset method for aggregates should reset the correct tracking fields
Failure/Error: @mock.visits("Mozilla Firefox").set(1, "2010-07-11")
NoMethodError:
undefined method `_selector' for #<TestModel:0x007fb392202f90>
# ./lib/trackoid/tracker.rb:79:in `set'
# ./spec/aggregates_spec.rb:289:in `block (3 levels) in <top (required)>'
19) Mongoid::Tracking::Aggregates When using reset method for aggregates should erase the correct tracking fields
Failure/Error: @mock.visits("Mozilla Firefox").set(1, "2010-07-11")
NoMethodError:
undefined method `_selector' for #<TestModel:0x007fb3920897e0>
# ./lib/trackoid/tracker.rb:79:in `set'
# ./spec/aggregates_spec.rb:289:in `block (3 levels) in <top (required)>'
20) Mongoid::Tracking::Aggregates Testing all accessors should return the correct values for .all_values
Failure/Error: @mock.visits("Mozilla Firefox").set(1, "2010-07-11")
NoMethodError:
undefined method `_selector' for #<TestModel:0x007fb391f28680>
# ./lib/trackoid/tracker.rb:79:in `set'
# ./spec/aggregates_spec.rb:389:in `block (3 levels) in <top (required)>'
21) Mongoid::Tracking::Aggregates Testing all accessors should return the all values for every aggregate
Failure/Error: @mock.visits("Mozilla Firefox").set(1, "2010-07-11")
NoMethodError:
undefined method `_selector' for #<TestModel:0x007fb391efc378>
# ./lib/trackoid/tracker.rb:79:in `set'
# ./spec/aggregates_spec.rb:389:in `block (3 levels) in <top (required)>'
22) Mongoid::Tracking::Aggregates Testing all accessors should return the correct first_date for every aggregate
Failure/Error: @mock.visits("Mozilla Firefox").set(1, "2010-07-11")
NoMethodError:
undefined method `_selector' for #<TestModel:0x007fb391eaa848>
# ./lib/trackoid/tracker.rb:79:in `set'
# ./spec/aggregates_spec.rb:389:in `block (3 levels) in <top (required)>'
23) Mongoid::Tracking::Aggregates Testing all accessors should return the correct last_date for every aggregate
Failure/Error: @mock.visits("Mozilla Firefox").set(1, "2010-07-11")
NoMethodError:
undefined method `_selector' for #<TestModel:0x007fb391e7ca60>
# ./lib/trackoid/tracker.rb:79:in `set'
# ./spec/aggregates_spec.rb:389:in `block (3 levels) in <top (required)>'
24) Mongoid::Tracking::Aggregates Testing all accessors should return the first value for aggregates
Failure/Error: @mock.visits("Mozilla Firefox").set(1, "2010-07-11")
NoMethodError:
undefined method `_selector' for #<TestModel:0x007fb391e42a68>
# ./lib/trackoid/tracker.rb:79:in `set'
# ./spec/aggregates_spec.rb:389:in `block (3 levels) in <top (required)>'
25) Mongoid::Tracking::Aggregates Testing all accessors should return the last value for aggregates
Failure/Error: @mock.visits("Mozilla Firefox").set(1, "2010-07-11")
NoMethodError:
undefined method `_selector' for #<TestModel:0x007fb391e28dc0>
# ./lib/trackoid/tracker.rb:79:in `set'
# ./spec/aggregates_spec.rb:389:in `block (3 levels) in <top (required)>'
26) Testing Readers with a model should return the correct values for a range using 'on'
Failure/Error: @mock.visits.set(1, "2010-07-11")
NoMethodError:
undefined method `_selector' for #<Test:0x007fb391d54d90>
# ./lib/trackoid/tracker.rb:79:in `set'
# ./spec/readers_spec.rb:20:in `block (2 levels) in <top (required)>'
27) Testing Readers with a model should return the correct values for .all_values
Failure/Error: @mock.visits.set(1, "2010-07-11")
NoMethodError:
undefined method `_selector' for #<Test:0x007fb391cfa548>
# ./lib/trackoid/tracker.rb:79:in `set'
# ./spec/readers_spec.rb:29:in `block (2 levels) in <top (required)>'
28) Testing Readers with a model should return the correct values for .all_values (Take II)
Failure/Error: @mock.visits.set(5, "2010-07-01")
NoMethodError:
undefined method `_selector' for #<Test:0x007fb391cb5718>
# ./lib/trackoid/tracker.rb:79:in `set'
# ./spec/readers_spec.rb:37:in `block (2 levels) in <top (required)>'
29) Mongoid::Tracking Testing TZ data with real models should correctly handle hours for my TimeZone
Failure/Error: @mock.visits.inc(t1)
NoMethodError:
undefined method `_selector' for #<Test:0x007fb392668620>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./lib/trackoid/tracker.rb:68:in `inc'
# ./spec/timezone_spec.rb:143:in `block (3 levels) in <top (required)>'
30) Mongoid::Tracking Testing TZ data with real models should correctly handle hours for UTC
Failure/Error: @mock.visits.inc(t1)
NoMethodError:
undefined method `_selector' for #<Test:0x007fb3925fd690>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./lib/trackoid/tracker.rb:68:in `inc'
# ./spec/timezone_spec.rb:154:in `block (3 levels) in <top (required)>'
31) Mongoid::Tracking Testing TZ data with real models Hours in Europe/Madrid (Winter time) should be shifted by 1 hour from UTC
Failure/Error: @mock.visits.inc(t1)
NoMethodError:
undefined method `_selector' for #<Test:0x007fb3925d5690>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./lib/trackoid/tracker.rb:68:in `inc'
# ./spec/timezone_spec.rb:167:in `block (3 levels) in <top (required)>'
32) Mongoid::Tracking Testing TZ data with real models Hours in Europe/Madrid (Summer time) should be shifted by 2 hour from UTC
Failure/Error: @mock.visits.inc(t1)
NoMethodError:
undefined method `_selector' for #<Test:0x007fb3925b63d0>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./lib/trackoid/tracker.rb:68:in `inc'
# ./spec/timezone_spec.rb:189:in `block (3 levels) in <top (required)>'
33) Mongoid::Tracking Testing TZ data with real models Hours in America/Los_Angeles (Winter time) should be shifted by -8 hours from UTC
Failure/Error: @mock.visits.inc(t1)
NoMethodError:
undefined method `_selector' for #<Test:0x007fb392579a20>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./lib/trackoid/tracker.rb:68:in `inc'
# ./spec/timezone_spec.rb:211:in `block (3 levels) in <top (required)>'
34) Mongoid::Tracking Testing TZ data with real models Hours in America/Los_Angeles (Summer time) should be shifted by -7 hours from UTC
Failure/Error: @mock.visits.inc(t1)
NoMethodError:
undefined method `_selector' for #<Test:0x007fb39251b628>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./lib/trackoid/tracker.rb:68:in `inc'
# ./spec/timezone_spec.rb:233:in `block (3 levels) in <top (required)>'
35) Mongoid::Tracking Testing TZ data with real models A value set at 10am on Madrid should appear as 01am on San Francisco
Failure/Error: @mock.visits.inc(time)
NoMethodError:
undefined method `_selector' for #<Test:0x007fb3924b6a98>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./lib/trackoid/tracker.rb:68:in `inc'
# ./spec/timezone_spec.rb:252:in `block (3 levels) in <top (required)>'
36) Mongoid::Tracking Testing TZ data with real models A value set at 10am on Madrid should appear as 01am on San Francisco (Using offsets)
Failure/Error: @mock.visits.inc(time)
NoMethodError:
undefined method `_selector' for #<Test:0x007fb392449380>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./lib/trackoid/tracker.rb:68:in `inc'
# ./spec/timezone_spec.rb:266:in `block (3 levels) in <top (required)>'
37) Mongoid::Tracking Testing TZ data with real models A value set now on Madrid should appear shifted 9 hours on San Francisco (Using offsets)
Failure/Error: @mock.visits.inc(time)
NoMethodError:
undefined method `_selector' for #<Test:0x007fb392388ef0>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./lib/trackoid/tracker.rb:68:in `inc'
# ./spec/timezone_spec.rb:280:in `block (3 levels) in <top (required)>'
38) Mongoid::Tracking when using a model in the database should increment visits stats for today
Failure/Error: @mock.visits.inc
NoMethodError:
undefined method `_selector' for #<Test:0x007fb391c917a0>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./lib/trackoid/tracker.rb:68:in `inc'
# ./spec/trackoid_spec.rb:116:in `block (3 levels) in <top (required)>'
39) Mongoid::Tracking when using a model in the database should increment another visits stats for today for a total of 2
Failure/Error: @mock.visits.inc
NoMethodError:
undefined method `_selector' for #<Test:0x007fb391c63620>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./lib/trackoid/tracker.rb:68:in `inc'
# ./spec/trackoid_spec.rb:121:in `block (3 levels) in <top (required)>'
40) Mongoid::Tracking when using a model in the database should also work for yesterday
Failure/Error: @mock.visits.inc(@today - 1.day)
NoMethodError:
undefined method `_selector' for #<Test:0x007fb391c46fe8>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./lib/trackoid/tracker.rb:68:in `inc'
# ./spec/trackoid_spec.rb:126:in `block (3 levels) in <top (required)>'
41) Mongoid::Tracking when using a model in the database should also work for yesterday if adding another visit (for a total of 2)
Failure/Error: @mock.visits.inc(@today - 1.day)
NoMethodError:
undefined method `_selector' for #<Test:0x007fb391c1af60>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./lib/trackoid/tracker.rb:68:in `inc'
# ./spec/trackoid_spec.rb:131:in `block (3 levels) in <top (required)>'
42) Mongoid::Tracking when using a model in the database then, the visits of today + yesterday must be the same
Failure/Error: @mock.visits.last_days(2).should == [2, 2]
expected: [2, 2]
got: [0, 0] (using ==)
Diff:
@@ -1,2 +1,2 @@
-[2, 2]
+[0, 0]
# ./spec/trackoid_spec.rb:136:in `block (3 levels) in <top (required)>'
43) Mongoid::Tracking when using a model in the database should have 4 visits for this test
Failure/Error: @mock.visits.last_days(2).sum.should == 4
expected: 4
got: 0 (using ==)
# ./spec/trackoid_spec.rb:140:in `block (3 levels) in <top (required)>'
44) Mongoid::Tracking when using a model in the database should correctly handle the 7 days
Failure/Error: @mock.visits.last_days.should == [0, 0, 0, 0, 0, 2, 2]
expected: [0, 0, 0, 0, 0, 2, 2]
got: [0, 0, 0, 0, 0, 0, 0] (using ==)
Diff:
@@ -1,2 +1,2 @@
-[0, 0, 0, 0, 0, 2, 2]
+[0, 0, 0, 0, 0, 0, 0]
# ./spec/trackoid_spec.rb:144:in `block (3 levels) in <top (required)>'
45) Mongoid::Tracking when using a model in the database string dates should work
Failure/Error: @mock.visits.inc("2010-07-11")
NoMethodError:
undefined method `_selector' for #<Test:0x007fb39183da78>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./lib/trackoid/tracker.rb:68:in `inc'
# ./spec/trackoid_spec.rb:148:in `block (3 levels) in <top (required)>'
46) Mongoid::Tracking when using a model in the database should give the first date with first_date
Failure/Error: [f.year, f.month, f.day, f.hour].should == [t.year, t.month, t.day, t.hour]
NoMethodError:
undefined method `year' for nil:NilClass
# ./spec/trackoid_spec.rb:155:in `block (3 levels) in <top (required)>'
47) Mongoid::Tracking when using a model in the database should give the last date with last_date
Failure/Error: @mock.visits.set(22, future)
NoMethodError:
undefined method `_selector' for #<Test:0x007fb391f2c078>
# ./lib/trackoid/tracker.rb:79:in `set'
# ./spec/trackoid_spec.rb:160:in `block (3 levels) in <top (required)>'
48) Mongoid::Tracking when using a model in the database should give the first value
Failure/Error: @mock.visits.first_value.should == 1
expected: 1
got: nil (using ==)
# ./spec/trackoid_spec.rb:166:in `block (3 levels) in <top (required)>'
49) Mongoid::Tracking when using a model in the database should give the last value
Failure/Error: @mock.visits.last_value.should == 22
expected: 22
got: nil (using ==)
# ./spec/trackoid_spec.rb:170:in `block (3 levels) in <top (required)>'
50) Mongoid::Tracking testing reader operations without reloading models 'set' operator must work
Failure/Error: @mock.visits.set(5)
NoMethodError:
undefined method `_selector' for #<Test:0x007fb3939470c0>
# ./lib/trackoid/tracker.rb:79:in `set'
# ./spec/trackoid_spec.rb:186:in `block (3 levels) in <top (required)>'
51) Mongoid::Tracking testing reader operations without reloading models 'set' operator must work on arbitrary days
Failure/Error: @mock.visits.set(5, Time.parse("2010-05-01"))
NoMethodError:
undefined method `_selector' for #<Test:0x007fb393934df8>
# ./lib/trackoid/tracker.rb:79:in `set'
# ./spec/trackoid_spec.rb:192:in `block (3 levels) in <top (required)>'
52) Mongoid::Tracking testing reader operations without reloading models 'add' operator must work
Failure/Error: @mock.visits.add(5)
NoMethodError:
undefined method `_selector' for #<Test:0x007fb3927ebba0>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./spec/trackoid_spec.rb:198:in `block (3 levels) in <top (required)>'
53) Mongoid::Tracking testing reader operations without reloading models 'add' operator must work on arbitrary days
Failure/Error: @mock.visits.add(5, Time.parse("2010-05-01"))
NoMethodError:
undefined method `_selector' for #<Test:0x007fb39278e400>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./spec/trackoid_spec.rb:204:in `block (3 levels) in <top (required)>'
54) Mongoid::Tracking testing reader operations without reloading models on() accessor must work on dates as String
Failure/Error: @mock.visits.on("2010-05-01").should == 10
expected: 10
got: 0 (using ==)
# ./spec/trackoid_spec.rb:211:in `block (3 levels) in <top (required)>'
55) Mongoid::Tracking testing reader operations without reloading models on() accessor must work on Date descendants
Failure/Error: @mock.visits.on(Date.parse("2010-05-01")).should == 10
expected: 10
got: 0 (using ==)
# ./spec/trackoid_spec.rb:216:in `block (3 levels) in <top (required)>'
56) Mongoid::Tracking testing reader operations without reloading models on() accessor must work on dates as Ranges
Failure/Error: @mock.visits.on(Time.parse("2010-04-30")..Time.parse("2010-05-02")).should == [0, 10, 0]
expected: [0, 10, 0]
got: [0, 0, 0] (using ==)
Diff:
@@ -1,2 +1,2 @@
-[0, 10, 0]
+[0, 0, 0]
# ./spec/trackoid_spec.rb:221:in `block (3 levels) in <top (required)>'
57) Mongoid::Tracking regression test for github issues should not raise undefined method [] for nil:NilClass when adding a new track into an existing object
Failure/Error: tm.something.inc
NoMethodError:
undefined method `_selector' for #<TestModel:0x007fb39258c058>
# ./lib/trackoid/tracker.rb:49:in `add'
# ./lib/trackoid/tracker.rb:68:in `inc'
# ./spec/trackoid_spec.rb:240:in `block (3 levels) in <top (required)>'
Finished in 1.73 seconds
143 examples, 57 failures
Failed examples:
rspec ./spec/aggregates_spec.rb:97 # Mongoid::Tracking::Aggregates should have Mongoid accessors defined
rspec ./spec/aggregates_spec.rb:172 # Mongoid::Tracking::Aggregates testing different object class for aggregation key should correctly save all aggregation keys as strings (inc)
rspec ./spec/aggregates_spec.rb:180 # Mongoid::Tracking::Aggregates testing different object class for aggregation key should correctly save all aggregation keys as strings (set)
rspec ./spec/aggregates_spec.rb:204 # Mongoid::Tracking::Aggregates when tracking a model with aggregation data should increment visits for all aggregated instances
rspec ./spec/aggregates_spec.rb:211 # Mongoid::Tracking::Aggregates when tracking a model with aggregation data should increment visits for specific aggregation keys
rspec ./spec/aggregates_spec.rb:223 # Mongoid::Tracking::Aggregates when tracking a model with aggregation data should have 1 visits today
rspec ./spec/aggregates_spec.rb:228 # Mongoid::Tracking::Aggregates when tracking a model with aggregation data should have 0 visits yesterday
rspec ./spec/aggregates_spec.rb:233 # Mongoid::Tracking::Aggregates when tracking a model with aggregation data should have 1 visits last 7 days
rspec ./spec/aggregates_spec.rb:238 # Mongoid::Tracking::Aggregates when tracking a model with aggregation data should work also for arbitrary days
rspec ./spec/aggregates_spec.rb:243 # Mongoid::Tracking::Aggregates when tracking a model with aggregation data should work adding 1 visit with different aggregation data
rspec ./spec/aggregates_spec.rb:252 # Mongoid::Tracking::Aggregates when tracking a model with aggregation data should return only values when specifying the aggregation key
rspec ./spec/aggregates_spec.rb:256 # Mongoid::Tracking::Aggregates when tracking a model with aggregation data should work also with set
rspec ./spec/aggregates_spec.rb:263 # Mongoid::Tracking::Aggregates when tracking a model with aggregation data let's check what happens when sorting the best browser...
rspec ./spec/aggregates_spec.rb:269 # Mongoid::Tracking::Aggregates when tracking a model with aggregation data should work without aggregation information
rspec ./spec/aggregates_spec.rb:306 # Mongoid::Tracking::Aggregates When using reset method for aggregates should have the correct values when using a value
rspec ./spec/aggregates_spec.rb:322 # Mongoid::Tracking::Aggregates When using reset method for aggregates should delete the values when using nil
rspec ./spec/aggregates_spec.rb:337 # Mongoid::Tracking::Aggregates When using reset method for aggregates erase method sould also work
rspec ./spec/aggregates_spec.rb:348 # Mongoid::Tracking::Aggregates When using reset method for aggregates should reset the correct tracking fields
rspec ./spec/aggregates_spec.rb:364 # Mongoid::Tracking::Aggregates When using reset method for aggregates should erase the correct tracking fields
rspec ./spec/aggregates_spec.rb:399 # Mongoid::Tracking::Aggregates Testing all accessors should return the correct values for .all_values
rspec ./spec/aggregates_spec.rb:403 # Mongoid::Tracking::Aggregates Testing all accessors should return the all values for every aggregate
rspec ./spec/aggregates_spec.rb:411 # Mongoid::Tracking::Aggregates Testing all accessors should return the correct first_date for every aggregate
rspec ./spec/aggregates_spec.rb:419 # Mongoid::Tracking::Aggregates Testing all accessors should return the correct last_date for every aggregate
rspec ./spec/aggregates_spec.rb:427 # Mongoid::Tracking::Aggregates Testing all accessors should return the first value for aggregates
rspec ./spec/aggregates_spec.rb:435 # Mongoid::Tracking::Aggregates Testing all accessors should return the last value for aggregates
rspec ./spec/readers_spec.rb:19 # Testing Readers with a model should return the correct values for a range using 'on'
rspec ./spec/readers_spec.rb:28 # Testing Readers with a model should return the correct values for .all_values
rspec ./spec/readers_spec.rb:36 # Testing Readers with a model should return the correct values for .all_values (Take II)
rspec ./spec/timezone_spec.rb:138 # Mongoid::Tracking Testing TZ data with real models should correctly handle hours for my TimeZone
rspec ./spec/timezone_spec.rb:149 # Mongoid::Tracking Testing TZ data with real models should correctly handle hours for UTC
rspec ./spec/timezone_spec.rb:160 # Mongoid::Tracking Testing TZ data with real models Hours in Europe/Madrid (Winter time) should be shifted by 1 hour from UTC
rspec ./spec/timezone_spec.rb:182 # Mongoid::Tracking Testing TZ data with real models Hours in Europe/Madrid (Summer time) should be shifted by 2 hour from UTC
rspec ./spec/timezone_spec.rb:204 # Mongoid::Tracking Testing TZ data with real models Hours in America/Los_Angeles (Winter time) should be shifted by -8 hours from UTC
rspec ./spec/timezone_spec.rb:226 # Mongoid::Tracking Testing TZ data with real models Hours in America/Los_Angeles (Summer time) should be shifted by -7 hours from UTC
rspec ./spec/timezone_spec.rb:248 # Mongoid::Tracking Testing TZ data with real models A value set at 10am on Madrid should appear as 01am on San Francisco
rspec ./spec/timezone_spec.rb:262 # Mongoid::Tracking Testing TZ data with real models A value set at 10am on Madrid should appear as 01am on San Francisco (Using offsets)
rspec ./spec/timezone_spec.rb:275 # Mongoid::Tracking Testing TZ data with real models A value set now on Madrid should appear shifted 9 hours on San Francisco (Using offsets)
rspec ./spec/trackoid_spec.rb:115 # Mongoid::Tracking when using a model in the database should increment visits stats for today
rspec ./spec/trackoid_spec.rb:120 # Mongoid::Tracking when using a model in the database should increment another visits stats for today for a total of 2
rspec ./spec/trackoid_spec.rb:125 # Mongoid::Tracking when using a model in the database should also work for yesterday
rspec ./spec/trackoid_spec.rb:130 # Mongoid::Tracking when using a model in the database should also work for yesterday if adding another visit (for a total of 2)
rspec ./spec/trackoid_spec.rb:135 # Mongoid::Tracking when using a model in the database then, the visits of today + yesterday must be the same
rspec ./spec/trackoid_spec.rb:139 # Mongoid::Tracking when using a model in the database should have 4 visits for this test
rspec ./spec/trackoid_spec.rb:143 # Mongoid::Tracking when using a model in the database should correctly handle the 7 days
rspec ./spec/trackoid_spec.rb:147 # Mongoid::Tracking when using a model in the database string dates should work
rspec ./spec/trackoid_spec.rb:152 # Mongoid::Tracking when using a model in the database should give the first date with first_date
rspec ./spec/trackoid_spec.rb:158 # Mongoid::Tracking when using a model in the database should give the last date with last_date
rspec ./spec/trackoid_spec.rb:165 # Mongoid::Tracking when using a model in the database should give the first value
rspec ./spec/trackoid_spec.rb:169 # Mongoid::Tracking when using a model in the database should give the last value
rspec ./spec/trackoid_spec.rb:185 # Mongoid::Tracking testing reader operations without reloading models 'set' operator must work
rspec ./spec/trackoid_spec.rb:191 # Mongoid::Tracking testing reader operations without reloading models 'set' operator must work on arbitrary days
rspec ./spec/trackoid_spec.rb:197 # Mongoid::Tracking testing reader operations without reloading models 'add' operator must work
rspec ./spec/trackoid_spec.rb:203 # Mongoid::Tracking testing reader operations without reloading models 'add' operator must work on arbitrary days
rspec ./spec/trackoid_spec.rb:209 # Mongoid::Tracking testing reader operations without reloading models on() accessor must work on dates as String
rspec ./spec/trackoid_spec.rb:214 # Mongoid::Tracking testing reader operations without reloading models on() accessor must work on Date descendants
rspec ./spec/trackoid_spec.rb:219 # Mongoid::Tracking testing reader operations without reloading models on() accessor must work on dates as Ranges
rspec ./spec/trackoid_spec.rb:226 # Mongoid::Tracking regression test for github issues should not raise undefined method [] for nil:NilClass when adding a new track into an existing object
rake aborted!
ruby -S bundle exec rspec spec/aggregates_spec.rb spec/ext/range_spec.rb spec/ext/time_spec.rb spec/reader_extender_spec.rb spec/readers_spec.rb spec/timezone_spec.rb spec/trackoid_spec.rb failed
Tasks: TOP => spec
(See full trace by running task with --trace)
trackoid git:master ❯
So after running trackoid for a while there's a lot of data printed out for tracked models.
This makes it hard to see the other attributes, how can I hide this?
Item.first
=>
#<Item views_data: {"15462"=>{"2"=>2, "7"=>2, "8"=>6, "10"=>1, "17"=>1}, "15463"=>{"10"=>1}, "15464"=>{"12"=>3}, "15465"=>{"9"=>1, "13"=>1}, "15466"=>{"23"=>1}, "15467"=>{"16"=>1}, "15468"=>{"0"=>1, "2"=>5, "10"=>1, "11"=>1, "12"=>1}, "15469"=>{"6"=>2, "7"=>3, "8"=>2, "10"=>2, "13"=>2, "14"=>3, "18"=>1, "20"=>5, "23"=>5}, "15470"=>{"0"=>8, "1"=>1, "3"=>4, "6"=>3, "7"=>5, "8"=>1, "9"=>6, "10"=>1, "17"=>4, "21"=>1, "22"=>1}, "15471"=>{"1"=>1, "6"=>2, "7"=>3, "8"=>2, "10"=>5, "11"=>1, "12"=>4, "13"=>1, "15"=>4, "16"=>3, "17"=>1, "19"=>8, "23"=>1}, "15472"=>{"0"=>7, "2"=>1, "5"=>4, "6"=>1, "10"=>1, "11"=>1, "12"=>1, "15"=>6, "16"=>1, "18"=>4, "20"=>6}, "15473"=>{"1"=>1, "2"=>3, "3"=>1, "11"=>1, "12"=>1, "13"=>1, "14"=>1, "15"=>1, "16"=>4, "17"=>1, "19"=>9, "20"=>1}, "15474"=>{"0"=>7, "1"=>8, "4"=>3, "5"=>6, "6"=>1, "7"=>2, "8"=>1, "9"=>9, "13"=>1, "14"=>2, "18"=>1, "19"=>3, "20"=>1}, "15475"=>{"0"=>1, "5"=>2, "7"=>1, "8"=>1, "9"=>2, "10"=>1, "11"=>7, "12"=>3, "13"=>3, "14"=>1, "15"=>3, "17"=>5, "19"=>8, "20"=>1, "21"=>3}, "15476"=>{"0"=>7, "2"=>1, "8"=>2, "9"=>7, "10"=>1, "11"=>2, "13"=>1, "15"=>1, "16"=>1, "18"=>2, "23"=>1}, "15477"=>{"1"=>1, "2"=>2, "3"=>1, "6"=>5, "7"=>1, "8"=>7, "10"=>2, "11"=>5, "12"=>5, "13"=>4, "14"=>1, "15"=>2, "18"=>4, "19"=>6, "20"=>4, "21"=>1}, "15478"=>{"0"=>7, "5"=>2, "8"=>2, "10"=>2, "16"=>2, "17"=>1, "18"=>1, "19"=>1, "20"=>2, "21"=>5, "22"=>5, "23"=>1}, "15479"=>{"0"=>2, "1"=>3, "3"=>3, "5"=>1, "6"=>2, "7"=>1, "10"=>3, "11"=>2, "14"=>1, "16"=>2, "20"=>8, "22"=>1, "23"=>1}, "15480"=>{"0"=>7, "10"=>5, "11"=>5, "13"=>1, "20"=>8, "23"=>1}, "15481"=>{"1"=>1, "2"=>1, "8"=>1, "9"=>2, "10"=>1, "11"=>1, "12"=>1, "13"=>2, "19"=>10, "20"=>10, "22"=>2}, "15482"=>{"0"=>15, "1"=>1, "2"=>1, "5"=>4, "8"=>3, "9"=>3, "13"=>1, "14"=>1, "16"=>1, "17"=>1, "23"=>1}, "15483"=>{"4"=>2, "5"=>1, "7"=>5, "9"=>1, "10"=>1, "17"=>8, "20"=>10, "21"=>4}, "15484"=>{"0"=>16, "5"=>4, "9"=>2, "10"=>3, "13"=>1, "15"=>4, "18"=>1, "19"=>1, "20"=>1}, "15485"=>{"1"=>1, "3"=>3, "4"=>5, "7"=>3, "8"=>3, "10"=>1, "14"=>2, "16"=>2, "17"=>2, "20"=>8, "21"=>10}, "15486"=>{"0"=>10, "2"=>4, "3"=>1, "5"=>1, "7"=>1, "9"=>1, "10"=>1, "16"=>5, "17"=>3, "19"=>1, "22"=>6, "23"=>1}, "15487"=>{"1"=>2, "2"=>1, "7"=>4, "8"=>6, "10"=>1, "11"=>1, "12"=>1, "13"=>4, "14"=>4, "15"=>1, "16"=>2, "21"=>10}, "15488"=>{"0"=>10, "5"=>2, "8"=>1, "9"=>5, "10"=>1, "11"=>2, "12"=>7, "18"=>4, "19"=>10, "22"=>1, "23"=>1}, "15489"=>{"1"=>3, "6"=>3, "7"=>4, "8"=>5, "9"=>1, "13"=>1, "18"=>1, "19"=>1, "21"=>11, "22"=>3, "23"=>7}, "15490"=>{"0"=>15, "7"=>1, "8"=>1, "9"=>1, "11"=>1, "12"=>3, "14"=>1, "17"=>1, "18"=>8, "19"=>3, "20"=>3, "21"=>1}, "15491"=>{"0"=>2, "1"=>1, "3"=>6, "7"=>2, "9"=>7, "14"=>2, "15"=>2, "21"=>1, "22"=>11}, "15492"=>{"0"=>1, "1"=>9, "3"=>1, "5"=>1, "7"=>2, "9"=>1, "11"=>1, "13"=>1, "14"=>9, "16"=>2, "17"=>13, "18"=>2, "19"=>3, "23"=>2}, "15493"=>{"0"=>1, "3"=>10, "5"=>1, "9"=>10, "14"=>2, "16"=>10, "18"=>1, "19"=>1, "22"=>10}, "15494"=>{"0"=>10, "1"=>10, "4"=>1, "5"=>10, "7"=>1, "10"=>2, "12"=>1, "14"=>6, "15"=>4, "19"=>10}, "15495"=>{"0"=>2, "1"=>1, "3"=>1, "4"=>10, "9"=>14, "10"=>2, "12"=>1, "14"=>1, "15"=>2, "16"=>1, "17"=>1, "18"=>10, "22"=>10, "23"=>10}, "15496"=>{"1"=>10, "4"=>2, "9"=>6, "10"=>15, "12"=>3, "14"=>10, "16"=>11, "18"=>1, "19"=>1}, "15497"=>{"3"=>10, "4"=>2, "5"=>2, "6"=>8, "7"=>1, "11"=>1, "16"=>1, "17"=>1, "18"=>13, "19"=>1, "21"=>10, "22"=>2}, "15498"=>{"2"=>1, "3"=>1, "7"=>1, "9"=>6, "10"=>4, "11"=>2, "12"=>2, "14"=>13, "16"=>1, "17"=>10, "19"=>1, "20"=>2, "22"=>3, "23"=>1}, "15499"=>{"0"=>2, "1"=>16, "2"=>2, "5"=>5, "6"=>12, "9"=>1, "10"=>1, "13"=>2, "14"=>2, "19"=>11, "21"=>7, "22"=>4, "23"=>1}, "15500"=>{"3"=>1, "5"=>1, "6"=>1, "10"=>2, "11"=>10, "12"=>1, "13"=>13, "15"=>1, "16"=>2, "18"=>2, "21"=>1, "23"=>12}, "15501"=>{"0"=>1, "3"=>1, "4"=>1, "6"=>20, "7"=>10, "9"=>1, "11"=>1, "14"=>7, "15"=>2, "16"=>6, "18"=>2, "21"=>1, "22"=>20}, "15502"=>{"0"=>2, "4"=>2, "6"=>1, "14"=>15, "15"=>7, "18"=>1, "20"=>2, "21"=>1}, "15503"=>{"0"=>1, "1"=>1, "8"=>1, "9"=>22, "12"=>5, "16"=>2, "22"=>1}, "15504"=>{"5"=>1, "8"=>1, "9"=>4}}, title: 'something'>
Support for sum appears to be broken?
track :likes
@listing.likes.sum returns
undefined method `sum' for #<Mongoid::Tracking::Tracker:0x007fbd0ace48d8>
@listing.likes_data.sum returns
["15672", {"17"=>1, "18"=>1}]
Thanks!!
It looks like Rails 3.1 introduced something that messed with the check for re-defining classes.
In development, the first request after the server starts goes through just fine, but all next requests have this error:
Started GET "/assets/restaurant.css" for 127.0.0.1 at 2011-07-07 13:20:02 +0200
Mongoid::Errors::ClassAlreadyDefined (RestaurantAggregates already defined, can't aggregate!):
app/models/restaurant.rb:77:in `<class:Restaurant>'
app/models/restaurant.rb:5:in `<top (required)>'
I suggest using https://github.com/thoughtbot/appraisal for testing with multiple Rails versions.
So I'm getting the following error, I guess something goes wrong in Aggregates.define_klass
but I can't figure out what it is.
Any ideas?
Thanks
/Users/speggey/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/rake/ext/module.rb:36:in `const_missing': uninitialized constant AdAggregates (NameError)
from /Users/speggey/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/inflector/methods.rb:229:in `block in constantize'
from /Users/speggey/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/inflector/methods.rb:228:in `each'
from /Users/speggey/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/inflector/methods.rb:228:in `constantize'
from /Users/speggey/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
from /Users/speggey/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/trackoid-0.3.7/lib/trackoid/aggregates.rb:111:in `define_aggregate_model'
from /Users/speggey/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/trackoid-0.3.7/lib/trackoid/aggregates.rb:64:in `aggregate'
from /Volumes/Produktioner/sites/rails/kyparn/lib/mongoid/view_tracking.rb:30:in `block in <module:ViewTracking>'
from /Users/speggey/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/concern.rb:119:in `class_eval'
from /Users/speggey/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/concern.rb:119:in `append_features'
from /Volumes/Produktioner/sites/rails/kyparn/app/models/ad.rb:2:in `include'
When accessing tracked documents I get this error raised from:
# Should we just "undef" this methods?
# They override the ones defined from Mongoid
define_method("#{name}_data") do
raise NoMethodError
end
define_method("#{name}_data=") do |m|
raise NoMethodError
end
How can I get arround this?
Update: Mongoid 2.4.4
The rest of the stack trace
mongoid (2.4.4) lib/mongoid/serialization.rb:45:in `block in serializable_hash'
mongoid (2.4.4) lib/mongoid/serialization.rb:45:in `map'
mongoid (2.4.4) lib/mongoid/serialization.rb:45:in `serializable_hash'
Hi @twoixter, hope all is well.
Any chance you could make a 0.4.1 release with the "newly" bumped Mongoid 3.1?
Thanks.
This error raises when we modify the model to add a "track" field for an object already saved in the database. @owner.read_attribute(@for)
in line 8 of traker.rb
returns nil
.
I'm getting a NoMethodError when trying to call to_json on a Mongoid model with tracking:
tracking.rb#62:
define_method("#{name}_data") do
raise NoMethodError
end
I've been able to get around it by overriding to_json in my model and removing any *_data attributes from the json hash.
Not got time to dig into this one but after an update to Ruby 2.0.0-p0, calls like:
@image.views.last_days(7).sum
Throws Mongoid::Tracking::ReaderExtender can't be coerced into Fixnum
.
@image.views.last_days(7).map{|v|v.to_f}.sum.to_i
Works as a hacky workaround - #to_i in the map function or #total both fail, to_f seems to work.
I have these trackers:
# Track exposure in search on site
track :views_on_web
# Track exposure in search on mobile
track :views_on_app
What would be the best approach to combine the data from them into one, I guess, virtual tracker?
i.e calling "views.sum" or "views.today" and get the combinated result.
Awesome gem btw, thanks!
I think it could be a good idea to be able to copy the trackoid information between objects. Fox example if you like to convert an object of the model A in the model B, you can't acces, read or write, to raw data, as you raise an error on tracking.rb file.
Is there any plan to support this?
I use rspec to test my models and views. How would i test if trackoid is implemented and incrementing a visit counter in an integration test?
In the documentation it says,
@user.failed_logins.sum
should return total, but the sum function doesn't seem to exist.
Hi,
Running into this issue when saving (without tracking anything, though doing some tracking work doesn't change anything) a model (specifically a User, Devise-backed). Can't figure it out. Rails 3.1.3, Mongoid is latest git, Ruby 1.9.3
Stack trace is this:
trackoid (0.3.7) lib/trackoid/tracker.rb:32:in `method_missing' /home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/validations/associated.rb:36:in `block in validate_each' /home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/validations/associated.rb:32:in `collect' /home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/validations/associated.rb:32:in `validate_each' activemodel (3.1.3) lib/active_model/validator.rb:153:in `block in validate' activemodel (3.1.3) lib/active_model/validator.rb:150:in `each' activemodel (3.1.3) lib/active_model/validator.rb:150:in `validate' activesupport (3.1.3) lib/active_support/callbacks.rb:302:in `_callback_before_168889' activesupport (3.1.3) lib/active_support/callbacks.rb:495:in `_run_validate_callbacks' activesupport (3.1.3) lib/active_support/callbacks.rb:81:in `run_callbacks' /home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/callbacks.rb:43:in `block in run_callbacks' /home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/callbacks.rb:68:in `call' /home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/callbacks.rb:68:in `run_cascading_callbacks' /home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/callbacks.rb:42:in `run_callbacks' activemodel (3.1.3) lib/active_model/validations.rb:212:in `run_validations!' activemodel (3.1.3) lib/active_model/validations/callbacks.rb:53:in `block in run_validations!' activesupport (3.1.3) lib/active_support/callbacks.rb:408:in `_run_validation_callbacks' activesupport (3.1.3) lib/active_support/callbacks.rb:81:in `run_callbacks' /home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/callbacks.rb:43:in `block in run_callbacks' /home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/callbacks.rb:68:in `call' /home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/callbacks.rb:68:in `run_cascading_callbacks' /home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/callbacks.rb:42:in `run_callbacks' activemodel (3.1.3) lib/active_model/validations/callbacks.rb:53:in `run_validations!' activemodel (3.1.3) lib/active_model/validations.rb:179:in `valid?' /home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/validations.rb:70:in `valid?' activemodel (3.1.3) lib/active_model/validations.rb:187:in `invalid?' /home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/persistence/modification.rb:22:in `prepare' /home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/persistence/operations/update.rb:43:in `persist' /home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/persistence.rb:91:in `update' /home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/persistence.rb:156:in `upsert' app/controllers/tags_controller.rb:82:in `unwatch'
The offending code setting this off is
current_user.watched_tags -= [tag] current_user.save
Both tag and user are tracked objects (with multiple tracked fields - 4 in user, 2 in tag, but no name collisions across models), watched_tags is a has_many array with no inverse.
Any ideas what's causing this or how to go about debugging it?
Should we clear all data on #clone?
Think so, but not sure...
I want to use trackoid into an embedded model (called Suscripcion). I declared it inside the model Suscripcion with an "track :reproducciones" but when I try to do an
suscr.reproducciones.inc
I receive an error in tracker.rb (line 48) like this:
Mongoid::Errors::InvalidCollection: translation missing: es.mongoid.errors.messages.invalid_collection
from /Users/user/.rvm/gems/ruby-1.9.2-p320/gems/mongoid-2.5.0/lib/mongoid/collections.rb:55:in `collection'
from /Users/user/.rvm/gems/ruby-1.9.2-p320/gems/mongoid-2.5.0/lib/mongoid/collections.rb:26:in `collection'
from /Users/user/.rvm/gems/ruby-1.9.2-p320/gems/trackoid-0.3.8/lib/trackoid/tracker.rb:48:in `add'
from /Users/user/.rvm/gems/ruby-1.9.2-p320/gems/trackoid-0.3.8/lib/trackoid/tracker.rb:68:in `inc'
So I think that there was a problem using it with embedded documents, possibly because they can't be accesed without the parent.
I have tried to do this in the parent likes as when you add an index to the child:
track "suscripcion.reproducciones"
But it wasn't work.
Any ideas?
PD: I can do a not-embedded document to use for trackoid, but reference it from an embedded document isn't too much clean...
Currently, an aggregation key must be a String. For example
aggregate :browsers do |b|
b.id # <= This gets automatically casted to a string by calling ".to_s"
end
It would be nice to allow for BSON::ObjectID or DateTime keys. However, this would not be possible without using Inheritance for the Aggregation class model. I can replace the :ns (namespace) field and use Inheritance instead (automatically using the :_type field).
At the moment trackoid require rails 3.x, it would be nice with support for rails 4.0.
Is it possible to create a Mongoid scope, or even a manual MongoDB query to sort documents by their number of tracked items? For example Page.desc(:visits)?
I've tried various techniques but since the data is nested in a Tracker instance I don't seem to have access to it.
Is' it possible to get aggregated value for tracker ?
I have a Page and a views tracker. So i can get access to numbers per one day, but how i can get aggregated value for the whole tracking period. For instance, I want to get top the most viewable photos for the whole tracking period.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.