Commit aaa72d0f by Rocky Duan

Merge branch 'master' into benchmark

parents 376aa1dc d45766c1
...@@ -51,7 +51,7 @@ namespace :db do ...@@ -51,7 +51,7 @@ namespace :db do
task :clean => :environment do task :clean => :environment do
Comment.delete_all Comment.delete_all
CommentThread.delete_all CommentThread.delete_all
CommentThread.recalculate_all_context_tag_weights! Content.recalculate_all_context_tag_weights!
User.delete_all User.delete_all
Notification.delete_all Notification.delete_all
Subscription.delete_all Subscription.delete_all
...@@ -183,7 +183,7 @@ namespace :db do ...@@ -183,7 +183,7 @@ namespace :db do
Comment.delete_all Comment.delete_all
CommentThread.delete_all CommentThread.delete_all
CommentThread.recalculate_all_context_tag_weights! Content.recalculate_all_context_tag_weights!
User.delete_all User.delete_all
Notification.delete_all Notification.delete_all
Subscription.delete_all Subscription.delete_all
......
...@@ -3,11 +3,9 @@ require_relative 'content' ...@@ -3,11 +3,9 @@ require_relative 'content'
class CommentThread < Content class CommentThread < Content
include Mongo::Voteable include Mongo::Voteable
include Mongoid::Timestamps include Mongoid::Timestamps
include Mongoid::TaggableWithContext
include Mongoid::TaggableWithContext::AggregationStrategy::RealTime
voteable self, :up => +1, :down => -1 voteable self, :up => +1, :down => -1
taggable separator: ',', default: []
field :comment_count, type: Integer, default: 0 field :comment_count, type: Integer, default: 0
field :title, type: String field :title, type: String
......
class Content class Content
include Mongoid::Document include Mongoid::Document
include Mongoid::TaggableWithContext
include Mongoid::TaggableWithContext::AggregationStrategy::RealTime
taggable separator: ',', default: []
def author_with_anonymity(attr=nil, attr_when_anonymous=nil) def author_with_anonymity(attr=nil, attr_when_anonymous=nil)
if not attr if not attr
......
...@@ -137,7 +137,7 @@ describe "app" do ...@@ -137,7 +137,7 @@ describe "app" do
end end
describe "GET /api/v1/threads/tags" do describe "GET /api/v1/threads/tags" do
it "get all tags used in threads" do it "get all tags used in threads" do
CommentThread.recalculate_all_context_tag_weights! Content.recalculate_all_context_tag_weights!
thread1 = CommentThread.all.to_a.first thread1 = CommentThread.all.to_a.first
thread2 = CommentThread.all.to_a.last thread2 = CommentThread.all.to_a.last
thread1.tags = "a, b, c" thread1.tags = "a, b, c"
...@@ -162,7 +162,7 @@ describe "app" do ...@@ -162,7 +162,7 @@ describe "app" do
end end
it "returns autocomplete results" do it "returns autocomplete results" do
CommentThread.delete_all CommentThread.delete_all
CommentThread.recalculate_all_context_tag_weights! Content.recalculate_all_context_tag_weights!
create_comment_thread "c++, clojure, common-lisp, c#, c, coffeescript" create_comment_thread "c++, clojure, common-lisp, c#, c, coffeescript"
create_comment_thread "c++, clojure, common-lisp, c#, c" create_comment_thread "c++, clojure, common-lisp, c#, c"
create_comment_thread "c++, clojure, common-lisp, c#" create_comment_thread "c++, clojure, common-lisp, c#"
......
...@@ -37,7 +37,7 @@ end ...@@ -37,7 +37,7 @@ end
def init_without_subscriptions def init_without_subscriptions
Comment.delete_all Comment.delete_all
CommentThread.delete_all CommentThread.delete_all
CommentThread.recalculate_all_context_tag_weights! Content.recalculate_all_context_tag_weights!
User.delete_all User.delete_all
Notification.delete_all Notification.delete_all
Subscription.delete_all Subscription.delete_all
...@@ -110,7 +110,7 @@ end ...@@ -110,7 +110,7 @@ end
def init_with_subscriptions def init_with_subscriptions
Comment.delete_all Comment.delete_all
CommentThread.delete_all CommentThread.delete_all
CommentThread.recalculate_all_context_tag_weights! Content.recalculate_all_context_tag_weights!
User.delete_all User.delete_all
Notification.delete_all Notification.delete_all
Subscription.delete_all Subscription.delete_all
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment