Mercurial > roundup-cc
annotate roundup_content_data/__init__.py @ 18:325757454907
Add TODO.creole file, with keyword extension proposal.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Mon, 09 Jul 2018 14:43:23 +0200 |
parents | adca5b3780d2 |
children | 3bb3d9a9f1b7 |
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": [], | |
30 "wish": [] | |
31 } | |
32 | |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
0
diff
changeset
|
33 #SQL |
0 | 34 |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
0
diff
changeset
|
35 #DEMO System |
0 | 36 SELECT_ALL = """ |
37 SELECT strftime("%Y-%m-%dT%H:%M:%S", timestamp), | |
38 critical, | |
39 urgent, | |
40 bug, | |
41 feature, | |
42 wish | |
43 FROM issues | |
44 ORDER BY timestamp | |
45 """ | |
46 | |
7
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
47 SELECT_WHERE = """ |
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
48 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
|
49 critical, |
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
50 urgent, |
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
51 bug, |
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
52 feature, |
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
53 wish |
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
54 FROM issues |
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
55 WHERE {} |
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
56 ORDER BY timestamp |
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
57 """ |
99e2e0e17103
Adding possibility and example to filter the entries.
Bernhard Reiter <bernhard@intevation.de>
parents:
1
diff
changeset
|
58 |
0 | 59 CREATE_DB = """ |
60 CREATE TABLE issues ( | |
61 timestamp TIMESTAMP NOT NULL UNIQUE DEFAULT current_timestamp, | |
62 critical INTEGER NOT NULL DEFAULT 0, | |
63 urgent INTEGER NOT NULL DEFAULT 0, | |
64 bug INTEGER NOT NULL DEFAULT 0, | |
65 feature INTEGER NOT NULL DEFAULT 0, | |
66 wish INTEGER NOT NULL DEFAULT 0 | |
67 ) | |
68 """ | |
69 | |
70 | |
71 INSERT_NEW = """ | |
72 INSERT INTO issues (critical, urgent, bug, feature, wish) | |
73 VALUES (?, ?, ?, ?, ?) | |
1
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
0
diff
changeset
|
74 """ |
2df45f6ecd81
new appereance (solid and dotted lines), resonsive layout, new legend,
sean
parents:
0
diff
changeset
|
75 |
17
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
76 |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
77 def build_sql_commands(list_of_columns: list): |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
78 """Build sql commands for use with collect_issues. |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
79 """ |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
80 create_db = ("""CREATE TABLE issues ( |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
81 timestamp TIMESTAMP NOT NULL UNIQUE DEFAULT current_timestamp, |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
82 """ + |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
83 ", ".join([c + " INTEGER NOT NULL DEFAULT 0" |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
84 for c in list_of_columns]) + ")") |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
85 |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
86 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
|
87 "VALUES (" + ("?, "*len(list_of_columns))[:-2]+ ")") |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
88 |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
89 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
|
90 ", ".join(list_of_columns)) |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
91 |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
92 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
|
93 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
|
94 |
adca5b3780d2
Add collecting no-prio issues. Restructure.
Bernhard Reiter <bernhard@intevation.de>
parents:
7
diff
changeset
|
95 # 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
|
96 return select_all, select_where, create_db, insert_new |