Module: CouchCloner::Query::ClassMethods
- Defined in:
- lib/couch_cloner/query.rb
Instance Method Summary collapse
- #count_by_clone_id_and_start(clone_id, start = nil) ⇒ Object
- #count_clone_ids! ⇒ Object
- #count_future_by_clone_id(clone_id) ⇒ Object
- #count_past_by_clone_id(clone_id) ⇒ Object
- #map_active_by_clone_id(clone_id) ⇒ Object
- #map_by_clone_id_and_start(clone_id, start = nil) ⇒ Object
- #map_clone_ids ⇒ Object
- #map_future_by_clone_id(clone_id) ⇒ Object
- #map_last_future_by_clone_id(clone_id) ⇒ Object
- #map_past_by_clone_id(clone_id) ⇒ Object
Instance Method Details
#count_by_clone_id_and_start(clone_id, start = nil) ⇒ Object
16 17 18 19 20 |
# File 'lib/couch_cloner/query.rb', line 16 def count_by_clone_id_and_start(clone_id, start=nil) count_by_clone_id_and_start_time. startkey!([clone_id, start]). endkey!([clone_id, {:end => nil}]) end |
#count_clone_ids! ⇒ Object
61 62 63 64 65 |
# File 'lib/couch_cloner/query.rb', line 61 def count_clone_ids! map_by_clone_id. reduce!(true). group!(true).get!['rows'].count end |
#count_future_by_clone_id(clone_id) ⇒ Object
35 36 37 38 39 |
# File 'lib/couch_cloner/query.rb', line 35 def count_future_by_clone_id(clone_id) count_by_clone_id_and_start_time. startkey!([clone_id, Time.now]). endkey!([clone_id, {:end => nil}]) end |
#count_past_by_clone_id(clone_id) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/couch_cloner/query.rb', line 48 def count_past_by_clone_id(clone_id) count_by_clone_id_and_start_time. startkey!([clone_id, Time.now]). endkey!([clone_id]). descending!(true) end |
#map_active_by_clone_id(clone_id) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/couch_cloner/query.rb', line 22 def map_active_by_clone_id(clone_id) map_by_clone_id_and_start_time. startkey!([clone_id, Time.now]). endkey!([clone_id]). descending!(true) end |
#map_by_clone_id_and_start(clone_id, start = nil) ⇒ Object
12 13 14 |
# File 'lib/couch_cloner/query.rb', line 12 def map_by_clone_id_and_start(clone_id, start=nil) map_by_clone_id_and_start_time.startkey!([clone_id, start]).endkey!([clone_id, {:end => nil}]) end |
#map_clone_ids ⇒ Object
55 56 57 58 59 |
# File 'lib/couch_cloner/query.rb', line 55 def map_clone_ids map_by_clone_id. reduce!(true). group!(true) end |
#map_future_by_clone_id(clone_id) ⇒ Object
29 30 31 32 33 |
# File 'lib/couch_cloner/query.rb', line 29 def map_future_by_clone_id(clone_id) map_by_clone_id_and_start_time. startkey!([clone_id, Time.now]). endkey!([clone_id, {:end => nil}]) end |
#map_last_future_by_clone_id(clone_id) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/couch_cloner/query.rb', line 67 def map_last_future_by_clone_id(clone_id) map_by_clone_id_and_start_time. startkey!([clone_id, {:end => nil}]). endkey!([clone_id]). descending!(true). limit!(1) end |
#map_past_by_clone_id(clone_id) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/couch_cloner/query.rb', line 41 def map_past_by_clone_id(clone_id) map_by_clone_id_and_start_time. startkey!([clone_id, Time.now]). endkey!([clone_id]). descending!(true) end |