Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
2f28add9
Commit
2f28add9
authored
7 years ago
by
Simon Belak
Browse files
Options
Downloads
Patches
Plain Diff
add cleanup task
parent
c4708ae0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/task/cleanup_temporary_computation_job_results.clj
+45
-0
45 additions, 0 deletions
...tabase/task/cleanup_temporary_computation_job_results.clj
with
45 additions
and
0 deletions
src/metabase/task/cleanup_temporary_computation_job_results.clj
0 → 100644
+
45
−
0
View file @
2f28add9
(
ns
metabase.task.cleanup-temporary-computation-job-results
"Tasks "
(
:require
[
clj-time.core
:as
t
]
[
clojurewerkz.quartzite
[
jobs
:as
jobs
]
[
triggers
:as
triggers
]]
[
clojurewerkz.quartzite.schedule.daily-interval
:as
interval
]
[
metabase.task
:as
task
]
[
toucan.db
:as
db
]))
(
def
^
:private
temporary-result-lifetime
(
t/minutes
1
))
(
defn-
cleanup-temporary-results!
[]
(
db/delete!
'ComputationJobResult
:created_at
[
:<
(
->
(
t/now
)
(
t/minus
temporary-result-lifetime
)
str
)]))
(
def
^
:private
^
:const
cleanup-job-key
"metabase.task.cleanup-temporary-computation-job-results.job"
)
(
def
^
:private
^
:const
cleanup-trigger-key
"metabase.task.cleanup-temporary-computation-job-results.trigger"
)
(
jobs/defjob
Cleanup
[
ctx
]
(
cleanup-temporary-results!
))
(
defonce
^
:private
cleanup-job
(
atom
nil
))
(
defonce
^
:private
cleanup-trigger
(
atom
nil
))
(
defn
task-init
"Automatically called during startup; start the job for sending pulses."
[]
(
reset!
cleanup-job
(
jobs/build
(
jobs/of-type
Cleanup
)
(
jobs/with-identity
(
jobs/key
cleanup-job-key
))))
(
reset!
cleanup-trigger
(
triggers/build
(
triggers/with-identity
(
triggers/key
cleanup-trigger-key
))
(
triggers/start-now
)
(
triggers/with-schedule
;; once per day at 3AM
(
interval/schedule
(
interval/starting-daily-at
(
interval/time-of-day
03
00
00
))))))
(
task/schedule-task!
@
cleanup-job
@
cleanup-trigger
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment