mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-14 21:27:04 +00:00
fixed TOTALS
This commit is contained in:
@@ -249,7 +249,7 @@ class JobQueue:
|
||||
if module in ["runlabel", "date", "test", "TOTAL"]:
|
||||
continue
|
||||
# print(i, module, f"length={len(self.results[module])} ")
|
||||
if (i in self.results[module]) and self.results[module][i]:
|
||||
if self.results[module][i]:
|
||||
total += float(self.results[module][i])
|
||||
return total
|
||||
|
||||
@@ -261,19 +261,17 @@ class JobQueue:
|
||||
data = json.load(f)
|
||||
for j in data:
|
||||
self.results[j] = data[j]
|
||||
# print(data[j])
|
||||
except:
|
||||
print(f"FAILURE parsing JSON file {self.tfile}")
|
||||
# Python bug: https://github.com/ShinNoNoir/twitterwebsearch/issues/12
|
||||
f.close()
|
||||
self.results["TOTAL"] = []
|
||||
for i in range(len(self.results["date"])):
|
||||
self.format_date(i)
|
||||
print(i, self.compute_total(i))
|
||||
self.results["TOTAL"].append(self.compute_total(i))
|
||||
|
||||
for j in self.results_order:
|
||||
# if j == "TOTAL":
|
||||
# # do not append None to total as it has not been computed yet.
|
||||
# continue
|
||||
self.results[j].append(None) # append a placeholder
|
||||
return True
|
||||
|
||||
@@ -357,6 +355,23 @@ class JobQueue:
|
||||
self.saveprofiles()
|
||||
return True
|
||||
|
||||
def format_date(self,i):
|
||||
# Calculate dates as days before last run
|
||||
r = self.results["date"]
|
||||
if r[i]:
|
||||
if i == len(r) - 1:
|
||||
print(" this", end=" ")
|
||||
else:
|
||||
# prints one place to the left of where you expect
|
||||
if r[len(r) - 1]:
|
||||
s = r[i] - r[len(r) - 1]
|
||||
elif r[len(r) - 2]:
|
||||
s = r[i] - r[len(r) - 2]
|
||||
else:
|
||||
s = 0
|
||||
days = (s) / (24 * 60 * 60)
|
||||
print(f"{days:8.2f}", end=" ")
|
||||
|
||||
def showprofile(self):
|
||||
"""Prints out the time it took to run the jobqueue"""
|
||||
RED = '\033[31m'
|
||||
@@ -386,20 +401,7 @@ class JobQueue:
|
||||
rp = " - "
|
||||
print("%8s" % rp, end=" ")
|
||||
elif k == "date":
|
||||
# Calculate dates as days before last run
|
||||
if r[i]:
|
||||
if i == len(r) - 1:
|
||||
print(" this", end=" ")
|
||||
else:
|
||||
# prints one place to the left of where you expect
|
||||
if r[len(r) - 1]:
|
||||
s = r[i] - r[len(r) - 1]
|
||||
elif r[len(r) - 2]:
|
||||
s = r[i] - r[len(r) - 2]
|
||||
else:
|
||||
s = 0
|
||||
days = (s) / (24 * 60 * 60)
|
||||
print(f"{days:8.2f}", end=" ")
|
||||
self.format_date(i)
|
||||
elif r[i]:
|
||||
print(f"{r[i]:8.1f}", end=" ")
|
||||
if i == len(r) - 1 and r[i - 1]:
|
||||
|
||||
Reference in New Issue
Block a user