2019-05-13 09:55:44 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-05-08 01:25:11 +08:00
|
|
|
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)
|
2019-05-17 01:45:20 +08:00
|
|
|
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
|
2019-05-08 01:25:11 +08:00
|
|
|
FROM reviewables
|
|
|
|
SQL
|
|
|
|
|
2019-05-23 05:23:45 +08:00
|
|
|
medium, high = res
|
|
|
|
|
|
|
|
Reviewable.set_priorities(medium: medium, high: high)
|
2019-05-08 01:25:11 +08:00
|
|
|
end
|
|
|
|
end
|