2020-11-25 11:39:05 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Jobs
|
|
|
|
class DeleteHiddenQueries < ::Jobs::Scheduled
|
|
|
|
every 7.days
|
|
|
|
|
|
|
|
def execute(args)
|
|
|
|
return unless SiteSetting.data_explorer_enabled
|
|
|
|
|
2023-03-22 17:29:08 -04:00
|
|
|
DiscourseDataExplorer::Query
|
2022-12-29 07:31:29 -05:00
|
|
|
.where("id > 0")
|
2020-11-25 11:39:05 -05:00
|
|
|
.where(hidden: true)
|
2022-12-29 07:31:29 -05:00
|
|
|
.where(
|
|
|
|
"(last_run_at IS NULL OR last_run_at < :days_ago) AND updated_at < :days_ago",
|
|
|
|
days_ago: 7.days.ago,
|
|
|
|
)
|
2020-11-25 11:39:05 -05:00
|
|
|
.delete_all
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|