discourse/app/jobs/scheduled/reviewable_priorities.rb
Robin Ward e74cd54fc6 REFACTOR: Replace score bonuses with low/med/high priorities
We removed score from the UX so it makes more sense to have sites set
priorities instead of score bonuses.
2019-05-23 11:54:45 -04:00

20 lines
534 B
Ruby

# frozen_string_literal: true
class Jobs::ReviewablePriorities < Jobs::Scheduled
every 1.day
def execute(args)
# We calculate the percentiles here for medium and high. Low is always 0 (all)
res = DB.query_single(<<~SQL)
SELECT COALESCE(PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY score), 0.0) AS medium,
COALESCE(PERCENTILE_DISC(0.85) WITHIN GROUP (ORDER BY score), 0.0) AS high
FROM reviewables
SQL
medium, high = res
Reviewable.set_priorities(medium: medium, high: high)
end
end