metrics: ingest_dashboard_config: rename seen to previous.
More accurately describes the new purpose.
This commit is contained in:
parent
4a1eb1701b
commit
1677557fae
12
metrics.py
12
metrics.py
@ -410,29 +410,29 @@ def dashboard_at_changed(api, filename, revision=None):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def ingest_dashboard_config(content):
|
def ingest_dashboard_config(content):
|
||||||
if not hasattr(ingest_dashboard_config, 'seen'):
|
if not hasattr(ingest_dashboard_config, 'previous'):
|
||||||
result = client.query('SELECT * FROM dashboard_config ORDER BY time DESC LIMIT 1')
|
result = client.query('SELECT * FROM dashboard_config ORDER BY time DESC LIMIT 1')
|
||||||
if result:
|
if result:
|
||||||
# Extract last point and remove zero values since no need to fill.
|
# Extract last point and remove zero values since no need to fill.
|
||||||
point = next(result.get_points())
|
point = next(result.get_points())
|
||||||
point = {k: v for (k, v) in point.iteritems() if k != 'time' and v != 0}
|
point = {k: v for (k, v) in point.iteritems() if k != 'time' and v != 0}
|
||||||
ingest_dashboard_config.seen = set(point.keys())
|
ingest_dashboard_config.previous = set(point.keys())
|
||||||
else:
|
else:
|
||||||
ingest_dashboard_config.seen = set()
|
ingest_dashboard_config.previous = set()
|
||||||
|
|
||||||
fields = {}
|
fields = {}
|
||||||
for key, value in content.items():
|
for key, value in content.items():
|
||||||
if key.startswith('repo_checker-binary-whitelist'):
|
if key.startswith('repo_checker-binary-whitelist'):
|
||||||
ingest_dashboard_config.seen.add(key)
|
ingest_dashboard_config.previous.add(key)
|
||||||
|
|
||||||
fields[key] = len(value.split())
|
fields[key] = len(value.split())
|
||||||
|
|
||||||
# Ensure any previously seen key are filled with zeros if no longer present
|
# Ensure any previously seen key are filled with zeros if no longer present
|
||||||
# to allow graphs to fill with previous.
|
# to allow graphs to fill with previous.
|
||||||
fields_keys = set(fields.keys())
|
fields_keys = set(fields.keys())
|
||||||
missing = ingest_dashboard_config.seen - fields_keys
|
missing = ingest_dashboard_config.previous - fields_keys
|
||||||
if len(missing):
|
if len(missing):
|
||||||
ingest_dashboard_config.seen = fields_keys
|
ingest_dashboard_config.previous = fields_keys
|
||||||
|
|
||||||
for key in missing:
|
for key in missing:
|
||||||
fields[key] = 0
|
fields[key] = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user