Skip to content

Commit

Permalink
SRCH-1401 change sayt_suggestions default limit to 1000 (#570)
Browse files Browse the repository at this point in the history
  • Loading branch information
MothOnMars authored Apr 16, 2020
1 parent 09a4747 commit ab2aacb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions lib/tasks/sayt_suggestions.rake
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
namespace :usasearch do
namespace :sayt_suggestions do

desc "generate top X SAYT suggestions from human Logstash searches for given YYYYMMDD date (defaults to an unlimited number for yesterday)"
desc 'generate top X SAYT suggestions from human Logstash searches
for given YYYYMMDD date (defaults to 1000 for yesterday)'.squish
task :compute, [:day, :limit] => [:environment] do |t, args|
args.with_defaults(:day => Date.yesterday.to_s(:number))
yyyymmdd = args.day.to_i
limit = args.limit.nil? ? 0 : args.limit.to_i
limit = args.limit.nil? ? 1000 : args.limit.to_i
SaytSuggestion.populate_for(yyyymmdd, limit)
end

desc "expire SAYT suggestions that have not been updated in X days (defaults to 30)"
desc 'expire SAYT suggestions that have not been updated in X days (defaults to 30)'
task :expire, [:days_back] => [:environment] do |t, args|
args.with_defaults(:days_back => 30)
SaytSuggestion.expire(args.days_back.to_i)
end
end
end
end
8 changes: 4 additions & 4 deletions spec/lib/tasks/sayt_suggestions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
context "when target day is specified" do
it "should populate sayt_suggestions for that given day" do
day = Date.current.to_s(:number).to_i
expect(SaytSuggestion).to receive(:populate_for).with(day, 0)
expect(SaytSuggestion).to receive(:populate_for).with(day, 1000)
@rake[task_name].invoke(day)
end
end

context "when target day is not specified" do
it "should default to yesterday" do
day = Date.yesterday.to_s(:number).to_i
expect(SaytSuggestion).to receive(:populate_for).with(day, 0)
expect(SaytSuggestion).to receive(:populate_for).with(day, 1000)
@rake[task_name].invoke
end
end
Expand All @@ -44,9 +44,9 @@
end

context "when limit is not specified" do
it "should pass 0 to #populate_for" do
it "should pass 1000 to #populate_for" do
day = Date.current.to_s(:number).to_i
expect(SaytSuggestion).to receive(:populate_for).with(day, 0)
expect(SaytSuggestion).to receive(:populate_for).with(day, 1000)
@rake[task_name].invoke(day)
end
end
Expand Down

0 comments on commit ab2aacb

Please sign in to comment.