aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service/model/build-status.scm
blob: d6fde3a7ea0f382c8d277eb4fa9afb67d097b2af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(define-module (guix-data-service model build-status)
  #:use-module (squee)
  #:export (build-statuses
            insert-build-status))

(define build-statuses
  '((-2 . "scheduled")
    (-1 . "started")
    (0 . "succeeded")
    (1 . "failed")
    (2 . "failed-dependency")
    (3 . "failed-other")
    (4 . "canceled")))

(define (insert-build-status conn internal-build-id
                             starttime stoptime status)
  (exec-query conn
              (string-append
               "INSERT INTO build_status "
               "(internal_build_id, starttime, stoptime, status) "
               "VALUES "
               "(" internal-build-id ", "
               (if (eq? starttime 0)
                   "NULL"
                   (string-append "to_timestamp("
                                  (number->string starttime)
                                  ")"))
               ", "
               (if (eq? stoptime 0)
                   "NULL"
                   (string-append "to_timestamp("
                                  (number->string stoptime)
                                  ")"))
               ", "
               "'" status "'"
               ")")))