Mercurial > roundup-cc
annotate roundup_content_data/__init__.py @ 25:7161ce4e7ab1
The web-based display is dynamically generated.
* All graphs are passed in one object. All graphs are passed in one object. The
graphs are generated iteratiev and assigned a color.
* roundup_cc.py can count how many issues are in which state.
author | Magnus Schieder <mschieder@intevation.de> |
---|---|
date | Mon, 12 Nov 2018 18:03:26 +0100 |
parents | 3bb3d9a9f1b7 |
children |
rev | line source |
---|---|
0 | 1 #!/usr/bin/env python |
2 | |
3 """ supplys the data needed to comunicate with the roundup-server, | |
4 and the sqlite database. Represents the types of errors used in roundup. | |
5 | |
6 author: Sascha L. Teichmann <sascha.teichmann@intevation.de> | |
7 author: Bernhard Reiter <bernhard@intevation.de> | |
8 author: Sean Engelhardt <sean.engelhardt@intevation.de> | |
9 | |
17
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
10 (c) 2010, 2015, 2018 by Intevation GmbH |
0 | 11 |
12 This is Free Software unter the terms of the | |
13 GNU GENERAL PUBLIC LICENSE Version 3 or later. | |
14 See http://www.gnu.org/licenses/gpl-3.0.txt for details | |
15 """ | |
16 | |
17 import os | |
17
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
18 from typing import List |
0 | 19 |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
0
diff
changeset
|
20 COLUMNS= [ |
0 | 21 "critical", "urgent", "bug", "feature", "wish", |
22 ] | |
23 | |
24 data_dict = { | |
25 "date": [], | |
26 "critical": [], | |
27 "urgent": [], | |
28 "bug": [], | |
29 "feature": [], | |
20
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
30 "wish": [], |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
31 "noPrio": [] |
0 | 32 } |
33 | |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
0
diff
changeset
|
34 #SQL |
0 | 35 |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
0
diff
changeset
|
36 #DEMO System |
0 | 37 SELECT_ALL = """ |
38 SELECT strftime("%Y-%m-%dT%H:%M:%S", timestamp), | |
39 critical, | |
40 urgent, | |
41 bug, | |
42 feature, | |
43 wish | |
44 FROM issues | |
45 ORDER BY timestamp | |
46 """ | |
47 | |
7
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
48 SELECT_WHERE = """ |
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
49 SELECT strftime("%Y-%m-%dT%H:%M:%S", timestamp), |
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
50 critical, |
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
51 urgent, |
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
52 bug, |
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
53 feature, |
20
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
54 wish, |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
55 None |
7
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
56 FROM issues |
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
57 WHERE {} |
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
58 ORDER BY timestamp |
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
59 """ |
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
60 |
0 | 61 CREATE_DB = """ |
62 CREATE TABLE issues ( | |
63 timestamp TIMESTAMP NOT NULL UNIQUE DEFAULT current_timestamp, | |
64 critical INTEGER NOT NULL DEFAULT 0, | |
65 urgent INTEGER NOT NULL DEFAULT 0, | |
66 bug INTEGER NOT NULL DEFAULT 0, | |
67 feature INTEGER NOT NULL DEFAULT 0, | |
68 wish INTEGER NOT NULL DEFAULT 0 | |
69 ) | |
70 """ | |
71 | |
72 | |
73 INSERT_NEW = """ | |
74 INSERT INTO issues (critical, urgent, bug, feature, wish) | |
75 VALUES (?, ?, ?, ?, ?) | |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
0
diff
changeset
|
76 """ |
20
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
77 def build_sql_select(columns): |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
78 return """ |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
79 SELECT strftime("%Y-%m-%dT%H:%M:%S", timestamp), |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
80 """+ columns + """ |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
81 FROM issues |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
82 WHERE {} |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
83 ORDER BY timestamp |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
84 """ |
3bb3d9a9f1b7
Filter by keywords and states.
Magnus Schieder <mschieder@intevation.de>
parents:
17
diff
changeset
|
85 |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
0
diff
changeset
|
86 |
17
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
87 |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
88 def build_sql_commands(list_of_columns: list): |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
89 """Build sql commands for use with collect_issues. |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
90 """ |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
91 create_db = ("""CREATE TABLE issues ( |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
92 timestamp TIMESTAMP NOT NULL UNIQUE DEFAULT current_timestamp, |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
93 """ + |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
94 ", ".join([c + " INTEGER NOT NULL DEFAULT 0" |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
95 for c in list_of_columns]) + ")") |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
96 |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
97 insert_new = ("INSERT INTO issues (" + ", ".join(list_of_columns) + ") " + |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
98 "VALUES (" + ("?, "*len(list_of_columns))[:-2]+ ")") |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
99 |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
100 select_tmpl = ("""SELECT strftime("%Y-%m-%dT%H:%M:%S", timestamp),""" + |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
101 ", ".join(list_of_columns)) |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
102 |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
103 select_all = select_tmpl + "FROM issues ORDER BY timestamp" |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
104 select_where = select_tmpl + "FROM issues WHERE {} ORDER BY timestamp" |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
105 |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
106 # print(select_all, select_where, create_db, insert_new) |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
107 return select_all, select_where, create_db, insert_new |