diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2014-08-01 16:43:00 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2014-08-01 16:48:49 +0200 |
commit | f0edc94f59ba82bef04d0576174035fd0f67a649 (patch) | |
tree | a1ac032ba389d1c91b7237283f88a58a34eea251 /src/lib/Bcfg2/Reporting/templatetags/bcfg2_tags.py | |
parent | ea634773e876cc054bdc4920567557462baa61a3 (diff) | |
download | bcfg2-f0edc94f59ba82bef04d0576174035fd0f67a649.tar.gz bcfg2-f0edc94f59ba82bef04d0576174035fd0f67a649.tar.bz2 bcfg2-f0edc94f59ba82bef04d0576174035fd0f67a649.zip |
Reporting: do not duplicate isstale functionality
The interaction entries have a isstale() method, we do not need a
template tag, that tries to figure out this on its own. The isstale()
method works even better: It knows, if the interaction is the current
interaction and compares the timestamp to the current time or (if it is
not the current one) it compares the timestamp to the timestamp of the
next interaction. So using the method of the model, you can browse the
interaction history and see, if the host was stale some time in the
past. Previously all interactions more than 24h ago were marked stale.
Diffstat (limited to 'src/lib/Bcfg2/Reporting/templatetags/bcfg2_tags.py')
-rw-r--r-- | src/lib/Bcfg2/Reporting/templatetags/bcfg2_tags.py | 15 |
1 files changed, 1 insertions, 14 deletions
diff --git a/src/lib/Bcfg2/Reporting/templatetags/bcfg2_tags.py b/src/lib/Bcfg2/Reporting/templatetags/bcfg2_tags.py index ceb9f5d91..4a93e77e0 100644 --- a/src/lib/Bcfg2/Reporting/templatetags/bcfg2_tags.py +++ b/src/lib/Bcfg2/Reporting/templatetags/bcfg2_tags.py @@ -189,19 +189,6 @@ def build_metric_list(mdict): @register.filter -def isstale(timestamp, entry_max=None): - """ - Check for a stale timestamp - - Compares two timestamps and returns True if the - difference is greater then 24 hours. - """ - if not entry_max: - entry_max = datetime.now() - return entry_max - timestamp > timedelta(hours=24) - - -@register.filter def sort_interactions_by_name(value): """ Sort an interaction list by client name @@ -318,7 +305,7 @@ def determine_client_state(entry): dirty. If the client is reporting dirty, this will figure out just _how_ dirty and adjust the color accordingly. """ - if isstale(entry.timestamp): + if entry.isstale(): return "stale-lineitem" if entry.state == 'clean': if entry.extra_count > 0: |