-
Notifications
You must be signed in to change notification settings - Fork 0
/
view.rkt
54 lines (42 loc) · 1.6 KB
/
view.rkt
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#lang racket
(require "structs.rkt"
web-server/http/response-structs
web-server/templates)
(provide list-cases)
(define (list-cases cases current-case bare-html?
start-work-url stop-work-url set-estimate-url
close-bug-url resolve-bug-url quick-interval-url)
(define-values (estimated unestimated) (estimated/unestimated cases))
(define (case-class case)
(cond [(and current-case
(string=? (case-id case)
(case-id current-case))) "case current"]
[(case-resolved? case) "case resolved"]
[else "case"]))
(define (wrapper content)
(include-template "wrapper-template.html"))
(define (content)
(include-template "content-template.html"))
(list #"text/html"
(if bare-html?
(content)
(wrapper (content)))))
(define (group-by-project/hash cases)
(for/fold ([table #hash()])
([case cases])
(hash-update table
(case-project case)
(curry cons case)
'())))
(define (group-by-project cases)
(define table (group-by-project/hash cases))
(define projects (for/list ([(key value) table])
(make-project key value)))
(sort projects string<? #:key project-title))
(define (estimated/unestimated cases)
(let*-values ([(estimated unestimated) (partition has-estimate? cases)])
(values (group-by-project estimated)
(group-by-project unestimated))))
(define (has-estimate? d)
(< 0 (case-estimate d)))
(define-struct project (title cases))