Commit aedc8c6b authored by Dave Griffiths's avatar Dave Griffiths
Browse files

date filtering for pups works

parent 624c930c
......@@ -273,10 +273,12 @@
" as a on a.entity_id = e.entity_id "
"join " table "_value_" (ktv-type ktv2)
" as b on b.entity_id = e.entity_id "
"where e.entity_type = ? and a.attribute_id = ? "
"and b.attribute_id = ? and a.value = ? and b.value > DateTime(?) ")
type (ktv-key ktv) (ktv-key ktv2) (ktv-value ktv) (ktv-value ktv2))))
(msg (db-status db))
"where e.entity_type = ? "
"and a.attribute_id = ? and a.value = ? "
"and b.attribute_id = ? and b.value > DateTime(?)"
)
type (ktv-key ktv) (ktv-value ktv) (ktv-key ktv2) (ktv-value ktv2))))
(msg "date select" (db-status db))
(if (null? s)
'()
(map
......@@ -354,6 +356,15 @@
(prof-end "db-all-where2")
r))
(define (db-all-newer db table type ktv ktv2)
(prof-start "db-all-where newer")
(let ((r (map
(lambda (i)
(get-entity db table i))
(all-entities-where-newer db table type ktv ktv2))))
(prof-end "db-all-where newer")
r))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; updating data
......
......@@ -199,10 +199,10 @@
(define (date->string d)
(string-append
(number->string (list-ref d 0))
"/"
(number->string (list-ref d 1))
"/"
(number->string (list-ref d 2))))
"-"
(substring (number->string (+ (list-ref d 1) 100)) 1 3)
"-"
(substring (number->string (+ (list-ref d 2) 100)) 1 3)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; random
......
......@@ -467,7 +467,7 @@
(list-ref d 5)))))
(define (db-mongooses-by-pack-pups)
(all-entities-where-newer
(db-all-newer
db "sync" "mongoose"
(ktv "pack-id" "varchar" (ktv-get (get-current 'pack '()) "unique_id"))
(ktv "dob" "varchar" (date->string (date-minus-months (date-time) 6)))))
......@@ -1274,7 +1274,7 @@
(list
(populate-grid-selector
"pf1-grid" "single"
(db-mongooses-by-pack)
(db-mongooses-by-pack-pups)
(lambda (individual)
(set-current! 'individual individual)
(entity-add-value! "id-focal-subject" "varchar" (ktv-get individual "unique_id"))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment