Mercurial > roundup-cc
comparison roundup_content_data/__init__.py @ 17:adca5b3780d2
Add collecting no-prio issues. Restructure.
* Move usage examples from collect_issues.py to examples/.
Also add a section about this to the readme. This should
make it easier to understand how it all works together.
As we have two examples now, hardcode the database filenames.
* Add a function to create the necessary database command from a list
of columns. This makes it easier to work with tracker that have
customized their priorities,
* Add an example how to collect no-prio issues in a database.
Note that the display part is not included.
* Cleanup roundup_content_data by removing db file name suggestions
and unused "reference db" command. This could be re-added for specific
installations if they need it, however it probably should be separated
as configuration.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Mon, 09 Jul 2018 12:28:28 +0200 |
parents | 99e2e0e17103 |
children | 3bb3d9a9f1b7 |
comparison
equal
deleted
inserted
replaced
16:5c24c116ba1f | 17:adca5b3780d2 |
---|---|
5 | 5 |
6 author: Sascha L. Teichmann <sascha.teichmann@intevation.de> | 6 author: Sascha L. Teichmann <sascha.teichmann@intevation.de> |
7 author: Bernhard Reiter <bernhard@intevation.de> | 7 author: Bernhard Reiter <bernhard@intevation.de> |
8 author: Sean Engelhardt <sean.engelhardt@intevation.de> | 8 author: Sean Engelhardt <sean.engelhardt@intevation.de> |
9 | 9 |
10 (c) 2010,2015 by Intevation GmbH | 10 (c) 2010, 2015, 2018 by Intevation GmbH |
11 | 11 |
12 This is Free Software unter the terms of the | 12 This is Free Software unter the terms of the |
13 GNU GENERAL PUBLIC LICENSE Version 3 or later. | 13 GNU GENERAL PUBLIC LICENSE Version 3 or later. |
14 See http://www.gnu.org/licenses/gpl-3.0.txt for details | 14 See http://www.gnu.org/licenses/gpl-3.0.txt for details |
15 """ | 15 """ |
16 | 16 |
17 import os | 17 import os |
18 | 18 from typing import List |
19 #Add desired sqlite databases here | |
20 DATABASE_REFERENCCE = os.path.dirname(os.path.realpath(__file__)) + "/test_reference.db" | |
21 DATABASE_DEMO = os.path.dirname(os.path.realpath(__file__)) + "/demo.db" | |
22 DATABASE_ERRORDB = os.path.dirname(os.path.realpath(__file__)) + "/errordatabase.db" | |
23 DATABASE_TECH_INTERN = os.path.dirname(os.path.realpath(__file__)) + "/tech_intern.db" | |
24 DATABASE_INT_TEST = os.path.dirname(os.path.realpath(__file__)) + "/int_test.db" | |
25 | 19 |
26 COLUMNS= [ | 20 COLUMNS= [ |
27 "critical", "urgent", "bug", "feature", "wish", | 21 "critical", "urgent", "bug", "feature", "wish", |
28 ] | 22 ] |
29 | 23 |
60 FROM issues | 54 FROM issues |
61 WHERE {} | 55 WHERE {} |
62 ORDER BY timestamp | 56 ORDER BY timestamp |
63 """ | 57 """ |
64 | 58 |
65 | |
66 CREATE_DB = """ | 59 CREATE_DB = """ |
67 CREATE TABLE issues ( | 60 CREATE TABLE issues ( |
68 timestamp TIMESTAMP NOT NULL UNIQUE DEFAULT current_timestamp, | 61 timestamp TIMESTAMP NOT NULL UNIQUE DEFAULT current_timestamp, |
69 critical INTEGER NOT NULL DEFAULT 0, | 62 critical INTEGER NOT NULL DEFAULT 0, |
70 urgent INTEGER NOT NULL DEFAULT 0, | 63 urgent INTEGER NOT NULL DEFAULT 0, |
78 INSERT_NEW = """ | 71 INSERT_NEW = """ |
79 INSERT INTO issues (critical, urgent, bug, feature, wish) | 72 INSERT INTO issues (critical, urgent, bug, feature, wish) |
80 VALUES (?, ?, ?, ?, ?) | 73 VALUES (?, ?, ?, ?, ?) |
81 """ | 74 """ |
82 | 75 |
83 #Referecen DB: | 76 |
84 SELECT_ALL_REFERENCE = """ | 77 def build_sql_commands(list_of_columns: list): |
85 SELECT strftime("%Y-%m-%dT%H:%M:%S", sample_time), | 78 """Build sql commands for use with collect_issues. |
86 critical, | 79 """ |
87 major, | 80 create_db = ("""CREATE TABLE issues ( |
88 crash, | 81 timestamp TIMESTAMP NOT NULL UNIQUE DEFAULT current_timestamp, |
89 normal, | 82 """ + |
90 minor, | 83 ", ".join([c + " INTEGER NOT NULL DEFAULT 0" |
91 wishlist | 84 for c in list_of_columns]) + ")") |
92 FROM issues | 85 |
93 ORDER BY sample_time | 86 insert_new = ("INSERT INTO issues (" + ", ".join(list_of_columns) + ") " + |
94 """ | 87 "VALUES (" + ("?, "*len(list_of_columns))[:-2]+ ")") |
88 | |
89 select_tmpl = ("""SELECT strftime("%Y-%m-%dT%H:%M:%S", timestamp),""" + | |
90 ", ".join(list_of_columns)) | |
91 | |
92 select_all = select_tmpl + "FROM issues ORDER BY timestamp" | |
93 select_where = select_tmpl + "FROM issues WHERE {} ORDER BY timestamp" | |
94 | |
95 # print(select_all, select_where, create_db, insert_new) | |
96 return select_all, select_where, create_db, insert_new |