Coverage report: /development/source/library/org/datagraph/spocq-shard/src/shell/usage-chart.lisp

KindCoveredAll%
expression071 0.0
branch00nil
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;;; -*- Mode: lisp; Syntax: ansi-common-lisp; Base: 10; Package: org.datagraph.spocq.implementation; -*-
2
 
3
 (in-package :org.datagraph.spocq.implementation)
4
 
5
 #|
6
 generate  statistics, particularly as csv or html for use in monitor displays
7
 
8
 (sb-ext:save-lisp-and-die "spocq-stats-cgi" :executable t :toplevel #'spocq.i::main-usage-chart)
9
 |#
10
 
11
 (defun main-usage-chart (&rest args &key
12
                                (query-parameters (sb-posix:getenv "QUERY_STRING"))
13
                                ((:response-content-type *response-content-type*) mime:application/VND.DYDRA.SPARQL-RESULTS+HTML+CHART)
14
                                &allow-other-keys)
15
   (handler-bind ((serious-condition
16
                   (lambda (condition)
17
                     (log-stacktrace "Error in query thread: ~a -> ~a." query-parameters condition)
18
                     (format *standard-output* "<html><body><pre>~a</pre></body></html>" condition)
19
                     (stop)
20
                     (return-from main-usage-chart))))
21
     (with-command-line-configuration (:allow-other-keys t (append (parse-query-parameters query-parameters) args))
22
       (setq *start-timestamp* (iso-time))
23
       (initialize-spocq :title (or (getarg "--title") "spocqugraph"))
24
       (log-info "Start usage-chart ~a." *start-timestamp*)
25
       (destructuring-bind (&key (limit (response-limit))
26
                                 (offset (response-offset))
27
                                 (end-time (getarg "--end-time"))
28
                                 (host (getarg "--host"))
29
                                 (repository (getarg "--repository"))
30
                                 &allow-other-keys)
31
                           *request-configuration*
32
         (pipe-usage-chart-query *standard-output*
33
                                 :host host
34
                                 :repository-id (cond (host (format nil "statistics/~a" host))
35
                                                      (*repository-id*)
36
                                                      (t (error "a host or repository-id is required.")))
37
                                 :end-time (when end-time (spocq.e:date-time end-time))
38
                                 :repository repository
39
                                 :content-type *response-content-type*
40
                                 :offset (etypecase offset (integer offset) (string (parse-integer offset)) (null nil))
41
                                 :limit (etypecase limit (integer limit) (string (parse-integer limit)) (null nil)))
42
         
43
         ;; make sure queues are closed
44
         (stop)))))
45
 
46
 #+(or)
47
 (progn
48
   (main-usage-chart :host "de4.dydra.com" :response-content-type mime:application/VND.DYDRA.SPARQL-RESULTS+HTML+D3)
49
   (main-usage-chart :response-content-type mime:application/VND.DYDRA.SPARQL-RESULTS+HTML+D3
50
                          :query-parameters "host=de4.dydra.com&end-time=2013-03-18T17:00:00Z&limit=10")
51
   ;; QUERY_STRING='start-time=2013-03-07T00:41:00Z&end-time=2013-03-07T17:00:00Z' sbcl --noinform --core sbcl-spocq.core --eval "(spocq.i::main-usage-chart)"  --noprint --no-userinit --response-content-type application/sparql-results+html+table
52
   ;; QUERY_STRING='host=de4.dydra.com&limit=100' usage-chart.sh
53
   ;; QUERY_STRING='host=end-time=&de4.dydra.com&limit=10&offset=10' /usr/local/lib/cgi-bin/usage-chart.sh
54
   
55
   
56
   (with-open-file (*standard-output* "tmp.html" :direction :output :if-does-not-exist :create :if-exists :supersede)
57
     (main-usage-chart :query-parameters "host=de4.dydra.com&end=2013-03-18T17:00:00Z" :response-content-type mime:application/VND.DYDRA.SPARQL-RESULTS+HTML+D3))
58
   
59
   (pipe-usage-chart-query *standard-output*
60
                                :repository-id "statistics/de4.dydra.com"
61
                                :start-time (spocq.e:date-time "2013-03-15T12:00:00Z")
62
                                :repository <http://de4.dydra.com/heltnormalt/dk-stage>
63
                                :content-type mime:application/VND.DYDRA.SPARQL-RESULTS+HTML+CHART)
64
   
65
   
66
   
67
   (main-usage-chart :repository-id "statistics/de4.dydra.com" :response-content-type mime:application/VND.DYDRA.SPARQL-RESULTS+HTML+D3
68
                          :query-parameters "start-time=2013-03-15T12:00:00Z")
69
   )