# HG changeset patch # User Bernhard Reiter # Date 1530891381 -7200 # Node ID d0c439d1e833c463a62c2bdac86500e51d1d1da3 # Parent b5f7a439bddd1d0e6ec5da311bd1a90f90e230c2 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. diff -r b5f7a439bddd -r d0c439d1e833 README.creole --- 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." diff -r b5f7a439bddd -r d0c439d1e833 collect_issues.py --- 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 author: Bernhard Reiter author: Sean Engelhardt -(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)) - - - - - - diff -r b5f7a439bddd -r d0c439d1e833 roundup_content_data/demo.db Binary file roundup_content_data/demo.db has changed