Skip to content

Commit

Permalink
fix: summary time travel
Browse files Browse the repository at this point in the history
Change-Id: I68e489f7d35b47aaadcbb842d9213e66147bd766
  • Loading branch information
grafuls committed May 26, 2020
1 parent d5d047b commit cbcda5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bin/quads-cli
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ def main(_args):
_args.datearg, "%Y-%m-%d %H:%M"
).isoformat()
try:
summary = quads.get_summary()
summary = quads.get_summary(**_kwargs)
except ConnectionError:
logger.error(
"Could not connect to the quads-server, verify service is up and running."
Expand Down
12 changes: 11 additions & 1 deletion quads/api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,16 @@ def GET(self, **data):
if self.name == "summary":
_clouds = model.Cloud.objects().all()
clouds_summary = []
total_count = 0
for cloud in _clouds:
if cloud.name == "cloud01":
count = model.Host.objects(cloud=cloud).count()
else:
count = self.model.current_schedule(cloud=cloud).count()
date = datetime.datetime.now()
if "date" in data:
date = datetime.datetime.strptime(data["date"], "%Y-%m-%dT%H:%M:%S")
count = self.model.current_schedule(cloud=cloud, date=date).count()
total_count += count
clouds_summary.append(
{
"name": cloud.name,
Expand All @@ -170,6 +175,11 @@ def GET(self, **data):
"validated": cloud.validated,
}
)
if "date" in data:
host_count = model.Host.objects().count()
for cloud in clouds_summary:
if cloud["name"] == "cloud01":
cloud["count"] = host_count - total_count

return json.dumps(clouds_summary)

Expand Down

0 comments on commit cbcda5f

Please sign in to comment.