Create interval objects from query

This commit is contained in:
contrapunctus 2022-04-18 20:09:13 +05:30
parent c9ab8b4f95
commit 0021f92e29
1 changed files with 19 additions and 11 deletions

View File

@ -2262,17 +2262,25 @@ ORDER BY interval_id DESC;")
"SELECT interval_id FROM date_intervals WHERE date_id = ?;"
date-id)))
(intervals
(multiple-value-bind (string values)
(yield
(select (:name :start_time :stop_time :properties)
(from :intervals)
(left-join :interval_names :using (:name_id))
(left-join :properties :using (:prop_id))
(where (:in :interval_id
(select (:interval_id)
(from :date_intervals)
(where (:= :date_id date-id)))))))
(apply #'execute-to-list connection string values)))
(loop
for (name start stop properties)
in (multiple-value-bind (string values)
(yield
(select (:name :start_time :stop_time :properties)
(from :intervals)
(left-join :interval_names :using (:name_id))
(left-join :properties :using (:prop_id))
(where (:in :interval_id
(select (:interval_id)
(from :date_intervals)
(where (:= :date_id date-id)))))))
(apply #'execute-to-list connection string values))
collect (make-instance 'chronometrist:interval
:activity name
:start start
:stop stop
:properties (when properties
(read-from-string properties)))))
(event-ids
(flatten (execute-to-list
connection