|
@@ -4,6 +4,7 @@
|
|
|
|
|
|
|
|
(require racket/cmdline
|
|
(require racket/cmdline
|
|
|
racket/date
|
|
racket/date
|
|
|
|
|
+ racket/list
|
|
|
db
|
|
db
|
|
|
"config.rkt") ; load configuration file
|
|
"config.rkt") ; load configuration file
|
|
|
|
|
|
|
@@ -17,6 +18,10 @@
|
|
|
; start and end date to sub-select proposals within a given range
|
|
; start and end date to sub-select proposals within a given range
|
|
|
(define start-date (make-parameter #f))
|
|
(define start-date (make-parameter #f))
|
|
|
(define end-date (make-parameter #f))
|
|
(define end-date (make-parameter #f))
|
|
|
|
|
+; if #t, use proposal type, submitting organiation, solicitation/call, and
|
|
|
|
|
+; telescope name from the most recently submitted (i.e., highest ID) proposal
|
|
|
|
|
+(define reuse-params (make-parameter #f))
|
|
|
|
|
+
|
|
|
; set up command line arguments
|
|
; set up command line arguments
|
|
|
(define mode (command-line
|
|
(define mode (command-line
|
|
|
#:program "update_proposals"
|
|
#:program "update_proposals"
|
|
@@ -25,6 +30,8 @@
|
|
|
(start-date sd)]
|
|
(start-date sd)]
|
|
|
[("-e" "--end-date") ed "End of date range (YYYY-MM-DD)"
|
|
[("-e" "--end-date") ed "End of date range (YYYY-MM-DD)"
|
|
|
(end-date ed)]
|
|
(end-date ed)]
|
|
|
|
|
+ [("-r" "--reuse-parameters") "Reuse/auto-fill proposal type, submitting organization, solicitation/call and telescope name from the most recently added proposal."
|
|
|
|
|
+ (reuse-params #t)]
|
|
|
#:args ([updatetype "help"]) ; (add, update, list-open, list-closed, help)
|
|
#:args ([updatetype "help"]) ; (add, update, list-open, list-closed, help)
|
|
|
updatetype))
|
|
updatetype))
|
|
|
|
|
|
|
@@ -38,12 +45,12 @@
|
|
|
(displayln " update\t\t - update a proposal with results.")
|
|
(displayln " update\t\t - update a proposal with results.")
|
|
|
(displayln " stats\t\t - print summary statistics.")
|
|
(displayln " stats\t\t - print summary statistics.")
|
|
|
(displayln " list-open\t - Show all submitted (but not resolved) proposals.")
|
|
(displayln " list-open\t - Show all submitted (but not resolved) proposals.")
|
|
|
- (displayln " list-closed\t - Show all resolved proposals.")
|
|
|
|
|
|
|
+ (displayln " list-closed\t - Show all resolved (accepted and rejected) proposals.")
|
|
|
(displayln " list-accepted\t - Show accepted proposals.")
|
|
(displayln " list-accepted\t - Show accepted proposals.")
|
|
|
(displayln " list-rejected\t - Show rejected proposals.")
|
|
(displayln " list-rejected\t - Show rejected proposals.")
|
|
|
(displayln " help\t\t - Show this help message.")
|
|
(displayln " help\t\t - Show this help message.")
|
|
|
(newline)
|
|
(newline)
|
|
|
- (displayln "Copyright 2019-2020, 2022 George C. Privon"))
|
|
|
|
|
|
|
+ (displayln "Copyright 2019-2020, 2022-2023 George C. Privon"))
|
|
|
|
|
|
|
|
; set up a condensed prompt for getting information
|
|
; set up a condensed prompt for getting information
|
|
|
(define (getinput prompt)
|
|
(define (getinput prompt)
|
|
@@ -69,25 +76,46 @@
|
|
|
(vector-ref entry 3)
|
|
(vector-ref entry 3)
|
|
|
"\"")))
|
|
"\"")))
|
|
|
|
|
|
|
|
|
|
+(define (get-last-proposal-call conn)
|
|
|
|
|
+ (println "Adopting proposal information from last submission")
|
|
|
|
|
+ (last-proposal-call conn))
|
|
|
|
|
+
|
|
|
|
|
+; get information from the most recent proposal submission
|
|
|
|
|
+(define (last-proposal-call conn)
|
|
|
|
|
+ (vector->list (query-row conn "SELECT type, organization, solicitation, telescope FROM proposals ORDER BY id DESC LIMIT 1")))
|
|
|
|
|
+
|
|
|
; add a new proposal to the database
|
|
; add a new proposal to the database
|
|
|
(define (addnew conn)
|
|
(define (addnew conn)
|
|
|
|
|
+ ; full list of input fileds that we will need (these will be the prompts
|
|
|
|
|
+ ; to the user)
|
|
|
|
|
+ (define input-fields (list "Proposal type"
|
|
|
|
|
+ "Submitting Organization"
|
|
|
|
|
+ "Solicitation/Call"
|
|
|
|
|
+ "Telescope"
|
|
|
|
|
+ "Proposal Title"
|
|
|
|
|
+ "PI"
|
|
|
|
|
+ "CoIs"
|
|
|
|
|
+ "Submit date (YYYY-MM-DD)"
|
|
|
|
|
+ "Organization's propsal ID"))
|
|
|
(displayln "Adding new proposal to database.")
|
|
(displayln "Adding new proposal to database.")
|
|
|
- ; user inputs proposal data
|
|
|
|
|
- (define proptype (getinput "Proposal type"))
|
|
|
|
|
- (define org (getinput "Submitting organization"))
|
|
|
|
|
- (define solic (getinput "Solitation/call"))
|
|
|
|
|
- (define tele (getinput "Telescope"))
|
|
|
|
|
- (define title (getinput "Proposal title"))
|
|
|
|
|
- (define pi (getinput "PI"))
|
|
|
|
|
- (define coi (getinput "CoIs"))
|
|
|
|
|
; assume all these proposals are submitted, don't ask the user
|
|
; assume all these proposals are submitted, don't ask the user
|
|
|
(define status "submitted")
|
|
(define status "submitted")
|
|
|
- (define submitdate (getinput "Submit date (YYYY-MM-DD)"))
|
|
|
|
|
- (define oID (getinput "Organization's proposal ID"))
|
|
|
|
|
|
|
+
|
|
|
|
|
+ ; get the proposal information
|
|
|
|
|
+ (define propinfo
|
|
|
|
|
+ (cond
|
|
|
|
|
+ ; if we're re-using parameters, get info from the most recent submission
|
|
|
|
|
+ ; and append the user input for the remaining fields
|
|
|
|
|
+ [(reuse-params) (append (get-last-proposal-call conn)
|
|
|
|
|
+ (map getinput (list-tail input-fields 4)))]
|
|
|
|
|
+ ; if not using previous information, ask the user for all inputs
|
|
|
|
|
+ [else (map getinput input-fields)]))
|
|
|
|
|
|
|
|
; do the INSERT into the Sqlite database
|
|
; do the INSERT into the Sqlite database
|
|
|
- (query-exec conn "INSERT INTO proposals (type, organization, solicitation, telescope, PI, title, CoI, status, submitdate, orgpropID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
|
|
|
|
- proptype org solic tele pi title coi status submitdate oID))
|
|
|
|
|
|
|
+ (let* ([add-proposal-info
|
|
|
|
|
+ (prepare conn "INSERT INTO proposals (type, organization, solicitation, telescope, title, PI, CoI, submitdate, orgpropID, status) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")])
|
|
|
|
|
+ (query-exec conn (bind-prepared-statement add-proposal-info
|
|
|
|
|
+ (flatten (list propinfo status))))))
|
|
|
|
|
|
|
|
; update an entry with new status (accepted, rejected, etc.)
|
|
; update an entry with new status (accepted, rejected, etc.)
|
|
|
(define (update conn ID)
|
|
(define (update conn ID)
|