Random Bits of Open Code

Check-in [d02d27340c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added code to remove the 50 oldest records which are over a month from last update
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:d02d27340c740f3c648633bf4533f4bb82c5ce6e
User & Date: jmoon18 2019-04-23 23:33:00
Context
2019-04-24
22:07
Added gen-peak-for-user to commmand processing check-in: d057b9bff9 user: jmoon18 tags: trunk
2019-04-23
23:33
Added code to remove the 50 oldest records which are over a month from last update check-in: d02d27340c user: jmoon18 tags: trunk
23:11
Fixed makefile to user userid rather than id, additional fixes for aggregation check-in: 720a34d403 user: jmoon18 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ringchart/runstats.scm.

55
56
57
58
59
60
61
62


63
64
65
66
67
68
69
     ((update) (doit "people.db" *top-mgr*))
     ((sumup)  (let ((db (open-db "jobs.db")))
		 (update-job-usage db)
		 (print "Update of usage in jobs.db complete.")
		 (close-database db)))
     ((rollup) (print "ERROR: manager id required.")(exit 1));;(regen-rollup *top-mgr*))
     ((datafiles) (create-datafiles #f *top-mgr*))
     ((cdis)   (print "CDIS update code needs to be recreated."))


     ((peak)   (gen-peak-data))
     ((repl)
      (set! toplevel-command (lambda (a . b) #f))
      (import csi)
      (import extras) ;; might not be needed
      (import readline)
      (import apropos)







|
>
>







55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
     ((update) (doit "people.db" *top-mgr*))
     ((sumup)  (let ((db (open-db "jobs.db")))
		 (update-job-usage db)
		 (print "Update of usage in jobs.db complete.")
		 (close-database db)))
     ((rollup) (print "ERROR: manager id required.")(exit 1));;(regen-rollup *top-mgr*))
     ((datafiles) (create-datafiles #f *top-mgr*))
     ((cdis)   
       (print "Removing 50 oldest records of people.db")
       (trim-db "people.db"))
     ((peak)   (gen-peak-data))
     ((repl)
      (set! toplevel-command (lambda (a . b) #f))
      (import csi)
      (import extras) ;; might not be needed
      (import readline)
      (import apropos)

Changes to ringchart/src/cstats.scm.

55
56
57
58
59
60
61




62
63
64
65
66
67
68
	       ;;"CREATE VIEW IF NOT EXISTS disk_usage AS SELECT owner AS username,SUM(dsize)/1e9 AS total FROM data GROUP BY owner;"


	       )
	 ) ;; )
    db))





(define (update-job-usage db #!optional (start-time #f)(end-time #f))
  (let* ((users (query (fold-rows
			(lambda (val res)(cons (car val) res))
			'())
		       (sql db "SELECT DISTINCT user FROM jobs ORDER BY user ASC;")))
	 (start-time   (or start-time (query fetch-value (sql db "SELECT min(finish_time) FROM jobs;"))))
	 (end-time     (or end-time   (query fetch-value (sql db "SELECT max(finish_time) FROM jobs;"))))







>
>
>
>







55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
	       ;;"CREATE VIEW IF NOT EXISTS disk_usage AS SELECT owner AS username,SUM(dsize)/1e9 AS total FROM data GROUP BY owner;"


	       )
	 ) ;; )
    db))

(define (trim-db fname)
  (let* ((db (open-db fname)))
    (exec (sql db "DELETE FROM people WHERE id IN (SELECT id FROM people where updated < ? limit 20)") (- (current-seconds) (* 60 60 24 30))))) 

(define (update-job-usage db #!optional (start-time #f)(end-time #f))
  (let* ((users (query (fold-rows
			(lambda (val res)(cons (car val) res))
			'())
		       (sql db "SELECT DISTINCT user FROM jobs ORDER BY user ASC;")))
	 (start-time   (or start-time (query fetch-value (sql db "SELECT min(finish_time) FROM jobs;"))))
	 (end-time     (or end-time   (query fetch-value (sql db "SELECT max(finish_time) FROM jobs;"))))