diff collect_issues.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 761ee2351f58
line wrap: on
line diff
--- a/collect_issues.py	Fri Nov 02 17:06:45 2018 +0100
+++ b/collect_issues.py	Mon Nov 12 18:03:26 2018 +0100
@@ -23,10 +23,18 @@
 import os
 
 
-CHECK_ROUNDUP_ORDER = "priority?@action=export_csv&@columns=id,order"
+# Getting all priority in their order.
+CHECK_ROUNDUP_ORDER_PRIO = "priority?@action=export_csv&@columns=id,order"
+# Getting all statuses in their order.
+CHECK_ROUNDUP_ORDER_STATUS = "status?@action=export_csv&@columns=id,order"
+# Getting keywords and their ids.
 CHECK_KEYWORD_ORDER = "keyword?@action=export_csv&@columns=id,name"
+# Getting states and their ids.
 CHECK_ROUNDUP_SEARCH_VALUES = "status?@action=export_csv&@columns=id,name&@filter=open&open=1"
-SEARCH_ROUNDUP = "issue?@action=export_csv&@columns=priority&@filter=status,keyword&@pagesize=500&@startwith=0&status={search_values}&keyword={keyword_values}"
+# Getting the priority of each issue with the filter status and keywords
+SEARCH_ROUNDUP_PRIO = "issue?@action=export_csv&@columns=priority&@filter=status,keyword&@pagesize=500&@startwith=0&status={search_values}&keyword={keyword_values}"
+# Getting the status of each issue with the filter keywords
+SEARCH_ROUNDUP_STATUS = "issue?@action=export_csv&@columns=status&@filter=keyword&@pagesize=500&@startwith=0&keyword={keyword_values}"
 
 
 def connect_to_server(params, baseurl):
@@ -82,11 +90,11 @@
 
 def get_status_ids(opener, baseurl, status):
 
-    status_csv = get_csv_from_server(opener, baseurl, CHECK_ROUNDUP_SEARCH_VALUES)
-
     if status == [""]:
         return ""
 
+    status_csv = get_csv_from_server(opener, baseurl, CHECK_ROUNDUP_SEARCH_VALUES)
+
     status_dict = {}
     for x in status_csv:
         status_dict[x["name"]] = x["id"]
@@ -113,14 +121,14 @@
         order_dict[row["id"]] = int(float(row["order"])) # int(float()) because the order-value is indeed "1.0, 2.0" etc
 
     for issue in issue_csv:
-        priority = issue["priority"]
+        priority = issue[issue_csv.fieldnames[0]]
 
         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
 
@@ -147,17 +155,22 @@
             con.close()
 
 
-def save_stats_in_db(login_parmeters, baseurl, db_file, columns, sql_create_db, sql_insert_in_db, keywords, status, include_no_prio=False):
+def save_stats_in_db(search, login_parmeters, baseurl, db_file, columns, sql_create_db, sql_insert_in_db, keywords, status, include_no_prio=False):
     try:
 
         opener = connect_to_server(login_parmeters, baseurl)
 
-        order_csv = get_csv_from_server(opener, baseurl, CHECK_ROUNDUP_ORDER)
-
         keywords_ids_url = get_keyword_ids(opener, baseurl, keywords)
 
-        status_ids_url =  get_status_ids(opener, baseurl, status)
-        formated_search_url = SEARCH_ROUNDUP.format(search_values=status_ids_url, keyword_values=keywords_ids_url)
+        if search == "prio":
+            order_csv = get_csv_from_server(opener, baseurl, CHECK_ROUNDUP_ORDER_PRIO)
+            status_ids_url =  get_status_ids(opener, baseurl, status)
+            formated_search_url = SEARCH_ROUNDUP_PRIO.format(search_values=status_ids_url, keyword_values=keywords_ids_url)
+        elif search == "status":
+            order_csv = get_csv_from_server(opener, baseurl, CHECK_ROUNDUP_ORDER_STATUS)
+            formated_search_url = SEARCH_ROUNDUP_STATUS.format(keyword_values=keywords_ids_url)
+        else:
+            print("Incorrect search parameter. (prio, status)")
 
         current_issues_csv = get_csv_from_server(opener, baseurl, formated_search_url)
 
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)