Class: Workarea::Help::Article
Constant Summary
collapse
- TOP_CATEGORY_COUNT =
3
- TOP_ARTICLE_COUNT =
3
Class Method Summary
collapse
#releasable?
add_worker, assert_valid_config!, async, caching_classes?, disable, enable, inline, #run_callbacks, workers, workers_list
#embedded_children
Class Method Details
.find_matching_url(url) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'app/models/workarea/help/article.rb', line 31
def self.find_matching_url(url)
results = []
all.each_by(50) do |article|
next if article.matching_url.blank?
regex = ::Regexp.new("^#{article.matching_url}$")
results << article if article.matching_url == url || regex =~ url
end
results
end
|
.top_categories ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
|
# File 'app/models/workarea/help/article.rb', line 44
def self.top_categories
aggregation = collection.aggregate(
[
{ '$group' => { '_id' => '$category', 'count' => { '$sum' => 1 } } },
{ '$sort' => { 'count' => -1 } },
{ '$limit' => TOP_CATEGORY_COUNT }
]
)
aggregation.to_a.map { |r| r['_id'] }
end
|