Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #63 from xebia/bug/schedule-fails-silently
Browse files Browse the repository at this point in the history
Bug/schedule fails silently
  • Loading branch information
skwakman committed Feb 29, 2016
2 parents c14cab9 + 0ac3033 commit e7e706d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.1.3

### Features and improvements
* Scheduled cleanup now logs a message at start and finish. This enables users to validate their schedule configuration.

### Bugfixes
* Errors during cleanup schedule no longer fail without logging an error.
* Fixes bug where runs are no longer cleaned up when there are multiple projects defined in VisualReview

## 0.1.2

### Features and improvements
Expand Down
23 changes: 16 additions & 7 deletions src/main/clojure/com/xebia/visualreview/schedule.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,32 @@
[slingshot.slingshot :as ex]
[clojure.tools.logging :as log]
[com.xebia.visualreview.service.cleanup :as cleanup]
[com.xebia.visualreview.service.persistence.database :as db]))
[com.xebia.visualreview.service.persistence.database :as db]
[com.xebia.visualreview.service.service-util :as sutil]))

(defn- try-catch-all [form]
(ex/try+
~form
(catch Object o#
(log/debug "Caught exception while running task"))))
(log/warn "Caught exception while running task" ~o#))
(catch Exception e
(log/warn "Caught exception while running task" e))))

(defn generate-cleanup-task
[]
{:id :cleanup-orphans-task
:handler (fn [t opts]
(do
(log/debug "Running cleanup task..")
(try-catch-all (cleanup/cleanup-old-runs! db/conn))
(try-catch-all (cleanup/cleanup-orphans! db/conn))
(log/debug "..cleanup task ended")))
(ex/try+
(sutil/attempt
(do
(log/info "Running cleanup task..")
(cleanup/cleanup-old-runs! db/conn)
(cleanup/cleanup-orphans! db/conn)
(log/info "..cleanup task ended"))
"Something went wrong during scheduled cleanup: %s"
:cleanup-error)
(catch Object o
(log/error (:message o)))))
:schedule (:cleanup-schedule com.xebia.visualreview.config/env)
:opts {}})

Expand Down
2 changes: 1 addition & 1 deletion src/main/clojure/com/xebia/visualreview/service/suite.clj
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
::delete-by-id-failed))

(def ^:private get-run-ids-per-suite-sql
"SELECT run.suite_id, GROUP_CONCAT(id ORDER BY START_TIME DESC SEPARATOR ',') as runids from RUN")
"SELECT run.suite_id, GROUP_CONCAT(id ORDER BY START_TIME DESC SEPARATOR ',') as runids from RUN GROUP BY SUITE_ID")
(defn get-run-ids-per-suite
"Returns {:suite-id <suite-id> :run-ids (lazy seq of run ids ordered by start-date desc)}"
[conn]
Expand Down

0 comments on commit e7e706d

Please sign in to comment.