recent builds method added to storage api
diff --git a/storage_api.py b/storage_api.py
index c0a9cb1..cf796eb 100644
--- a/storage_api.py
+++ b/storage_api.py
@@ -86,6 +86,27 @@
return -1
+ def recent_builds(self):
+ i = self.work_sheet.row_count - 1
+ d = {}
+ result = []
+
+ while i > 0:
+ vals = self.work_sheet.row_values(i)
+
+ if vals["type"] not in d:
+ d[vals["type"]] = vals
+ m = Measurement()
+ m.build = vals.pop("build_id")
+ m.build_type = vals.pop("type")
+ m.md5 = vals.pop("iso_md5")
+ m.results = {k: vals[k] for k in vals.keys()}
+ result.append(m)
+
+ i -= 1
+
+ return result
+
class DiskStorage(Storage):
def __init__(self, file_name):
@@ -120,3 +141,24 @@
return m
return None
+ def recent_builds(self):
+ with open(self.file_name, "rt") as f:
+ raw_data = f.read()
+ document = json.loads(raw_data)
+ d = {}
+ result = []
+
+ for i in range(len(document) - 1, -1, - 1):
+ if document[i]["type"] not in d:
+ d[document[i]["type"]] = document[i]
+
+ for k in d.keys():
+ m = Measurement()
+ m.build = d[k].pop("build_id")
+ m.build_type = d[k].pop("type")
+ m.md5 = d[k].pop("iso_md5")
+ m.results = {k: d[key] for key in d.keys()}
+ result.append(m)
+
+ return d
+