-
-
Save Licenser/f8a9496b3173dffc62c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn sql-stats-for [db years month users] | |
(-> | |
(cql/table db :kont_project) | |
(cql/join | |
(cql/table db :internaltask) | |
(cql/where (= :kont_project.taskID :internaltask.id))) | |
(cql/aggregate [[:sum/hours :as :total] | |
[:YEAR/date :as :year] | |
[:internaltask.description :as :task] | |
[:MONTH/date :as :month] | |
[:taskID :as :tid]] | |
[:MONTH/date :taskID]) | |
(cql/select | |
(cql/where (and | |
(if (empty? users) nil (in :kont_project.userID users)) | |
(in :kont_project.taskID [5 6 7 8 9 11 12 13 14 15 16 18]) | |
(cqlp/restrict (str " AND YEAR(`kont_project`.`date`) IN (" (apply str (interpose "," (map int years))) ")")) | |
(cqlp/restrict (str " AND MONTH(`kont_project`.`date`) IN (" (apply str (interpose "," (map int month))) ")"))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment