Random Bits of Open Code

Check-in [720a34d403]
Login

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

Overview
Comment:Fixed makefile to user userid rather than id, additional fixes for aggregation
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:720a34d4031b1316c47d0e77f978575c1867d701
User & Date: jmoon18 2019-04-23 23:11:22
Context
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
00:38
Group Updater should be integrated. Still problems with runstats datafiles check-in: 455b1ac6ad user: jmoon18 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ringchart/Makefile.

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 	@echo TARGETFILES: $(TARGETFILES)

% : %.scm
	csc $<

genhtml : runstats
	runstats sumup
	runstats rollup $(TOPMGRID)
	runstats datafiles
	mkdir -p html
	mv *.html html

jobs.db : output.db
	echo Please copy output.db to jobs.db

output.db : process $(INPUTFILES)







|
|







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 	@echo TARGETFILES: $(TARGETFILES)

% : %.scm
	csc $<

genhtml : runstats
	runstats sumup
	runstats rollup $(TOPMGRUID)
	runstats datafiles $(TOPMGRUID)
	mkdir -p html
	mv *.html html

jobs.db : output.db
	echo Please copy output.db to jobs.db

output.db : process $(INPUTFILES)

Changes to ringchart/runstats.scm.

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
..
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

85
86
87

88
89
90
91
  ;; (import csi)
  (import readline)
  (import apropos)
  (install-history-file (get-environment-variable "HOME") ".runstats_history") ;;  [homedir] [filename] [nlines])
  (current-input-port (make-readline-port "runstats> "))
  (repl))

(match (argv)
  ((_) (print help))
  ((_ cmd)
   (case (string->symbol cmd)
     ((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*))
................................................................................
      (import readline)
      (import apropos)
      (import cstats)
      (install-history-file (get-environment-variable "HOME") ".runstats_history") ;;  [homedir] [filename] [nlines])
      (current-input-port (make-readline-port "runstats> "))
      (repl))
     (else (print "Command " cmd " not recognised"))))
  ((_ cmd param)
   (let* ((db       (open-db "people.db"))
	  (id       (let ((rec (get-person-by-uid db param)))
		      (if rec
			  (car rec)
			  -1))))
     (case (string->symbol cmd)
       ((all)
	(doit "people.db" id)
	(regen-rollup id)

	(create-datafiles #f id)
	(close-database db))
       ((rollup)(regen-rollup id))

       ((update)(doit "people.db" id))
       (else (print "Command " cmd " with param " param " not recognised")))
     )))
   







|
|
|







 







|









>



>




44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
..
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
  ;; (import csi)
  (import readline)
  (import apropos)
  (install-history-file (get-environment-variable "HOME") ".runstats_history") ;;  [homedir] [filename] [nlines])
  (current-input-port (make-readline-port "runstats> "))
  (repl))

(match (command-line-arguments)
  (() (print help))
  ((cmd)
   (case (string->symbol cmd)
     ((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*))
................................................................................
      (import readline)
      (import apropos)
      (import cstats)
      (install-history-file (get-environment-variable "HOME") ".runstats_history") ;;  [homedir] [filename] [nlines])
      (current-input-port (make-readline-port "runstats> "))
      (repl))
     (else (print "Command " cmd " not recognised"))))
  ((cmd param)
   (let* ((db       (open-db "people.db"))
	  (id       (let ((rec (get-person-by-uid db param)))
		      (if rec
			  (car rec)
			  -1))))
     (case (string->symbol cmd)
       ((all)
	(doit "people.db" id)
	(regen-rollup id)
        (print "ID: " id)
	(create-datafiles #f id)
	(close-database db))
       ((rollup)(regen-rollup id))
       ((datafiles)(create-datafiles #f id)) 
       ((update)(doit "people.db" id))
       (else (print "Command " cmd " with param " param " not recognised")))
     )))
   

Changes to ringchart/src/cstats.scm.

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
...
100
101
102
103
104
105
106

107

108
109
110
111
112
113
114
     (lambda ()
       (for-each
	(lambda (user)
	  (let* ((total (query fetch-value (sql db "SELECT sum(duration*num_cpus) AS total FROM jobs WHERE user=?;") user))
		 (sum (/ total delta)))
	    (print "update sum for " user ": " sum)
            (handle-exceptions exn (print "No user: " user) (with-input-from-pipe (conc "update-people --user " user " --db people.db")
                (lambda () #f    )))
	    (exec (sql db "INSERT INTO usage (username,total) VALUES (?,?);") user sum)))
	users)))))

;;======================================================================
;; 

(define (get-person-by-id db id)
................................................................................
	res)))

(define (get-person-by-uid db uid)
  (let ((res (query fetch-row (sql db "SELECT id,uid,mgr_id FROM people WHERE uid=?;") uid)))
    (if (null? res)
        (handle-exceptions 
          exn 

          (print "Get-person-by-uid exception: " uid ) 

          (begin
            (with-input-from-pipe (conc "update-people --user " uid " --db people.db")
              (lambda ()
                #f
              ))
            (query fetch-row (sql db "SELECT id,uid,mgr_id FROM people WHERE uid=?;") uid)
          ))







|







 







>
|
>







73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
...
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
     (lambda ()
       (for-each
	(lambda (user)
	  (let* ((total (query fetch-value (sql db "SELECT sum(duration*num_cpus) AS total FROM jobs WHERE user=?;") user))
		 (sum (/ total delta)))
	    (print "update sum for " user ": " sum)
            (handle-exceptions exn (print "No user: " user) (with-input-from-pipe (conc "update-people --user " user " --db people.db")
                (lambda () (if #f (print (read-line)))    )))
	    (exec (sql db "INSERT INTO usage (username,total) VALUES (?,?);") user sum)))
	users)))))

;;======================================================================
;; 

(define (get-person-by-id db id)
................................................................................
	res)))

(define (get-person-by-uid db uid)
  (let ((res (query fetch-row (sql db "SELECT id,uid,mgr_id FROM people WHERE uid=?;") uid)))
    (if (null? res)
        (handle-exceptions 
          exn 
          (begin 
            (print "Get-person-by-uid exception: " uid ) 
            #f)
          (begin
            (with-input-from-pipe (conc "update-people --user " uid " --db people.db")
              (lambda ()
                #f
              ))
            (query fetch-row (sql db "SELECT id,uid,mgr_id FROM people WHERE uid=?;") uid)
          ))