-
-
Save bhenry/8dbce1459f942b64c3a2 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 spreadsheet | |
"takes a collection of scores and makes output for a *.xls" | |
[cards] | |
(str | |
(format "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t\n" | |
"Operator First" | |
"Operator Last" | |
"Operator Username" | |
"Client Account Number" | |
"Client Name" | |
"Evaluator First" | |
"Evaluator Last" | |
"Evaluator Username" | |
"Entry Time" | |
"Call Time" | |
"Scored" | |
"Possible" | |
"Percentage" | |
"ID") | |
(apply str | |
(for [sc cards] | |
(format "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t\n" | |
(:first-name (:operator sc)) | |
(:last-name (:operator sc)) | |
(:user-name (:operator sc)) | |
(:account-number (:client sc)) | |
(:account-name (:client sc)) | |
(:first-name (:evaluator sc)) | |
(:last-name (:evaluator sc)) | |
(:user-name (:evaluator sc)) | |
(html/display-date (:timestamp sc)) | |
(html/display-date (:call-date sc)) | |
(html/display-number (:scored (:grade sc))) | |
(html/display-number (:possible (:grade sc))) | |
(format "%.2f%%" (* 100.0 (:percentage (:grade sc)))) | |
(str (:_id sc))))))) | |
(defn export | |
[cards] | |
{:status 200 | |
:headers {"Content-Type" "application/octet-stream" | |
"Content-Disposition" (format | |
"attachment; filename=qa-%s.xls" | |
(html/display-date (date) false)) | |
"Pragma" "no-cache" | |
"Expires" "0"} | |
:body (spreadsheet cards)}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment