discourse-data-explorer/app/jobs/scheduled/delete_hidden_queries.rb
Arpit Jalan f70c95271a
FEATURE: destroy old hidden queries (#82)
This commit adds a scheduled job to hard delete queries that are hidden and

- were last run more than 7 days ago
- were updated more than 7 days ago
2020-11-25 22:09:05 +05:30

17 lines
411 B
Ruby

# frozen_string_literal: true
module Jobs
class DeleteHiddenQueries < ::Jobs::Scheduled
every 7.days
def execute(args)
return unless SiteSetting.data_explorer_enabled
DataExplorer::Query.where("id > 0")
.where(hidden: true)
.where("(last_run_at IS NULL OR last_run_at < :days_ago) AND updated_at < :days_ago", days_ago: 7.days.ago)
.delete_all
end
end
end