mongoid_taggable_with_context 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 330460cba0321c62c198a6ac426fa2f33452e252
|
4
|
+
data.tar.gz: 260e96cbacc75cdecdbe58553219f3f1b2f720fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c7476f6fc9dd74b48fce65eeb1878f1765d919845c2a92bead00dda8503f1b0e171746742a61ca698da1b274210367b213bdf006398b2091098b1e411497285
|
7
|
+
data.tar.gz: 1b9f6d7f64ed234bee25d7b2141ed2a6151ffad9fe3fddb75fb7fe9f667d687eeddf10042f14b713c0a3cefb80f8537551ce5138d535bbb189138d43ce011a22
|
data/Gemfile
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
module Mongoid::TaggableWithContext::AggregationStrategy
|
2
|
+
module RealTimeGroupBy
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
include Mongoid::TaggableWithContext::AggregationStrategy::RealTime
|
5
|
+
|
6
|
+
module ClassMethods
|
7
|
+
def tag_name_attribute
|
8
|
+
"_name"
|
9
|
+
end
|
10
|
+
|
11
|
+
def tags_for(context, group_by, conditions={})
|
12
|
+
results = if group_by
|
13
|
+
query(context, group_by).to_a.map{ |t| t[tag_name_attribute] }
|
14
|
+
else
|
15
|
+
super(context, conditions)
|
16
|
+
end
|
17
|
+
results.uniq
|
18
|
+
end
|
19
|
+
|
20
|
+
def tags_with_weight_for(context, group_by, conditions={})
|
21
|
+
results = if group_by
|
22
|
+
query(context, group_by).to_a.map{ |t| [t[tag_name_attribute], t["value"].to_i] }
|
23
|
+
else
|
24
|
+
super(context, conditions)
|
25
|
+
end
|
26
|
+
|
27
|
+
tag_hash = {}
|
28
|
+
results.each do |tag, weight|
|
29
|
+
tag_hash[tag] ||= 0
|
30
|
+
tag_hash[tag] += weight
|
31
|
+
end
|
32
|
+
tag_hash.to_a
|
33
|
+
end
|
34
|
+
|
35
|
+
protected
|
36
|
+
def query(context, group_by)
|
37
|
+
aggregation_database_collection_for(context).find({value: {"$gt" => 0 }, group_by: group_by}).sort(tag_name_attribute.to_sym => 1)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
protected
|
42
|
+
|
43
|
+
def get_conditions(context, tag)
|
44
|
+
conditions = {self.class.tag_name_attribute.to_sym => tag}
|
45
|
+
group_by = self.class.get_tag_group_by_field_for(context)
|
46
|
+
if group_by
|
47
|
+
conditions.merge!({group_by: self.send(group_by)})
|
48
|
+
end
|
49
|
+
conditions
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "mongoid_taggable_with_context"
|
8
|
-
s.version = "1.1.
|
8
|
+
s.version = "1.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Aaron Qian", "Luca G. Soave", "John Shields", "Wilker Lucio", "Ches Martin"]
|
12
|
-
s.date = "2013-05-
|
12
|
+
s.date = "2013-05-26"
|
13
13
|
s.description = "Add multiple tag fields on Mongoid documents with aggregation capability."
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE.txt",
|
@@ -26,12 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
"lib/mongoid/taggable_with_context.rb",
|
27
27
|
"lib/mongoid/taggable_with_context/aggregation_strategy/map_reduce.rb",
|
28
28
|
"lib/mongoid/taggable_with_context/aggregation_strategy/real_time.rb",
|
29
|
-
|
30
|
-
# and by adding lib/mongoid/taggable_with_context/deprecations.rb
|
31
|
-
#
|
32
|
-
#"lib/mongoid/taggable_with_context/group_by/aggregation_strategy/real_time.rb",
|
33
|
-
#"lib/mongoid/taggable_with_context/group_by/taggable_with_context.rb",
|
34
|
-
#
|
29
|
+
"lib/mongoid/taggable_with_context/aggregation_strategy/real_time_group_by.rb",
|
35
30
|
"lib/mongoid/taggable_with_context/deprecations.rb",
|
36
31
|
"lib/mongoid/taggable_with_context/version.rb",
|
37
32
|
"lib/mongoid_taggable_with_context.rb",
|
@@ -42,22 +37,22 @@ Gem::Specification.new do |s|
|
|
42
37
|
s.homepage = "http://github.com/lgs/mongoid_taggable_with_context"
|
43
38
|
s.licenses = ["MIT"]
|
44
39
|
s.require_paths = ["lib"]
|
45
|
-
s.rubygems_version = "
|
40
|
+
s.rubygems_version = "2.0.3"
|
46
41
|
s.summary = "Mongoid taggable behaviour"
|
47
42
|
|
48
43
|
if s.respond_to? :specification_version then
|
49
|
-
s.specification_version =
|
44
|
+
s.specification_version = 4
|
50
45
|
|
51
46
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
47
|
s.add_runtime_dependency(%q<mongoid>, [">= 3.0.0"])
|
53
|
-
s.add_development_dependency(%q<
|
48
|
+
s.add_development_dependency(%q<rake>, [">= 0"])
|
54
49
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
55
50
|
s.add_development_dependency(%q<yard>, [">= 0"])
|
56
51
|
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
57
52
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
58
53
|
else
|
59
54
|
s.add_dependency(%q<mongoid>, [">= 3.0.0"])
|
60
|
-
s.add_dependency(%q<
|
55
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
61
56
|
s.add_dependency(%q<rspec>, [">= 0"])
|
62
57
|
s.add_dependency(%q<yard>, [">= 0"])
|
63
58
|
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
@@ -65,7 +60,7 @@ Gem::Specification.new do |s|
|
|
65
60
|
end
|
66
61
|
else
|
67
62
|
s.add_dependency(%q<mongoid>, [">= 3.0.0"])
|
68
|
-
s.add_dependency(%q<
|
63
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
69
64
|
s.add_dependency(%q<rspec>, [">= 0"])
|
70
65
|
s.add_dependency(%q<yard>, [">= 0"])
|
71
66
|
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_taggable_with_context
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Qian
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2013-05-
|
15
|
+
date: 2013-05-26 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: mongoid
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: 3.0.0
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
|
-
name:
|
32
|
+
name: rake
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
34
34
|
requirements:
|
35
35
|
- - '>='
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/mongoid/taggable_with_context.rb
|
117
117
|
- lib/mongoid/taggable_with_context/aggregation_strategy/map_reduce.rb
|
118
118
|
- lib/mongoid/taggable_with_context/aggregation_strategy/real_time.rb
|
119
|
+
- lib/mongoid/taggable_with_context/aggregation_strategy/real_time_group_by.rb
|
119
120
|
- lib/mongoid/taggable_with_context/deprecations.rb
|
120
121
|
- lib/mongoid/taggable_with_context/version.rb
|
121
122
|
- lib/mongoid_taggable_with_context.rb
|
@@ -144,7 +145,7 @@ requirements: []
|
|
144
145
|
rubyforge_project:
|
145
146
|
rubygems_version: 2.0.3
|
146
147
|
signing_key:
|
147
|
-
specification_version:
|
148
|
+
specification_version: 4
|
148
149
|
summary: Mongoid taggable behaviour
|
149
150
|
test_files: []
|
150
151
|
has_rdoc:
|