changeset 15:d0c439d1e833

Prepare for tracker entries without priority. * Extend issues_to_quantities to count entries with priority 'None'. The regular classic template enforces a priority value, but some trackers don't, e.g. the 'fast-decomposed' variant used by Intevation (https://hg.intevation.de/roundup/fast-decomposed/) uses other fields for a scrum like workflow that show the order of issues as a float value. In order to get all issues, we also have to collect them. Implement it in a backwards compatible manner for save_stats_in_db() by a keyword argument that is off by default. This is just a preparation as the database must also accept an additional column. * Cleanup some superfluous whitespace, remove an unused import and add copyright 208 year.
author Bernhard Reiter <bernhard@intevation.de>
date Fri, 06 Jul 2018 17:36:21 +0200
parents b5f7a439bddd
children 5c24c116ba1f
files README.creole collect_issues.py roundup_content_data/demo.db
diffstat 3 files changed, 15 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/README.creole	Sun Jan 31 15:41:35 2016 +0100
+++ b/README.creole	Fri Jul 06 17:36:21 2018 +0200
@@ -7,7 +7,7 @@
 === Notes
 
 When migrating to 3:99c68ebfb3b9, Nov 30 17:46:22 2015
-you need to add the print statements for the content-type header 
+you need to add the print statements for the content-type header
 to all of your cgi scripts.
 
 Bottledash may have a fork
@@ -19,5 +19,5 @@
 
 === Included
 
-http://d3js.org/    	initially used with 3.5.5
+http://d3js.org/    initially used with 3.5.5
   """Library released under BSD license. Copyright 2015 Mike Bostock."
--- a/collect_issues.py	Sun Jan 31 15:41:35 2016 +0100
+++ b/collect_issues.py	Fri Jul 06 17:36:21 2018 +0200
@@ -1,12 +1,11 @@
 #!/usr/bin/env python3
-
 """ Fetch issues from a roundup-tracker and save them in a databse.
 
 author: Sascha L. Teichmann <sascha.teichmann@intevation.de>
 author: Bernhard Reiter <bernhard@intevation.de>
 author: Sean Engelhardt <sean.engelhardt@intevation.de>
 
-(c) 2010,2015 by Intevation GmbH
+(c) 2010, 2015, 2018 by Intevation GmbH
 
 This is Free Software unter the terms of the
 GNU GENERAL PUBLIC LICENSE Version 3 or later.
@@ -34,7 +33,6 @@
 import io
 import sqlite3 as db
 import os
-import roundup_content_data as rcd
 
 
 CHECK_ROUNDUP_ORDER = "priority?@action=export_csv&@columns=id,order"
@@ -92,8 +90,13 @@
 
 
 def issues_to_quantities(issue_csv, columns, orders_csv):
+    """Count issues per priority.
 
-    quantities = [0] * len(columns)
+    Returns: a list of ints, containing how often a prio occurred [:-1]
+             in order of the priorities, with the last being the "None" prio
+    """
+
+    quantities = [0] * (len(columns) +1)
     order_dict = {}
 
     #convert the csv-dict reader to real dict
@@ -105,8 +108,10 @@
 
         if priority.isdigit() == True :
             quantities[order_dict[priority] -1 ] += 1
+        else: #  no priority set
+            quantities[-1] += 1
 
-    # print("quantities : " + str(quantities))
+    #  print("quantities : " + str(quantities))
 
     return quantities
 
@@ -133,7 +138,7 @@
             con.close()
 
 
-def save_stats_in_db(login_parmeters, baseurl, db_file, columns, sql_create_db, sql_insert_in_db, searchurl=False):
+def save_stats_in_db(login_parmeters, baseurl, db_file, columns, sql_create_db, sql_insert_in_db, searchurl=False, include_no_prio=False):
     try:
 
         opener = connect_to_server(login_parmeters, baseurl)
@@ -151,14 +156,10 @@
         opener.close()
 
         quantities = issues_to_quantities(current_issues_csv, columns, order_csv)
+        if not include_no_prio:
+            quantities = quantities[:-1]
 
         save_issues_to_db(quantities, db_file, sql_create_db, sql_insert_in_db)
 
     except urllib.error.URLError as e:
         print("No Valid Connection to server : " + baseurl + "\nerror: " + str(e))
-
-
-
-
-
-
Binary file roundup_content_data/demo.db has changed
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)