Compare commits

..

No commits in common. "develop" and "master" have entirely different histories.

2 changed files with 8 additions and 41 deletions

View file

@ -229,19 +229,15 @@ def run_forever(
writer.writerow((lease.ip, lease.mac, lease.hostname or "???"))
elif output_file.endswith(".html"):
last_change = None
last_change_natural = None
for ts, leases in groupby(
_fetch_leases(db, now - timedelta(days=7)), key=attrgetter("ts")
):
humans_present = [lease for lease in leases if lease.is_human]
if (len(humans_present) > 0) != (status.level > 0):
last_change = {"ts": ts, "leases": humans_present}
last_change_natural = humanize.naturaltime(datetime.now() - ts)
break
log_entry = namedtuple(
"log_entry", ("ts", "ts_natural", "state", "lease")
)
log_entry = namedtuple("log_entry", ("ts", "state", "lease"))
log = []
last_seen = []
for ts, leases in groupby(
@ -251,24 +247,10 @@ def run_forever(
leases = list(leases)
for lease in leases:
if lease.mac not in (l.mac for l in last_seen):
log.append(
log_entry(
ts,
humanize.naturaltime(datetime.now() - ts),
True,
lease,
)
)
log.append(log_entry(ts, True, lease))
for lease in last_seen:
if lease.mac not in (l.mac for l in leases):
log.append(
log_entry(
ts,
humanize.naturaltime(datetime.now() - ts),
False,
lease,
)
)
log.append(log_entry(ts, False, lease))
last_seen = leases
collapse_thresh = timedelta(minutes=10)
@ -319,7 +301,6 @@ def run_forever(
leases=registered_leases,
status=status,
last_change=last_change,
last_change_natural=last_change_natural,
log=log,
leaderboard=leaderboard,
internal=False,
@ -333,7 +314,6 @@ def run_forever(
leases=registered_leases,
status=status,
last_change=last_change,
last_change_natural=last_change_natural,
log=log,
leaderboard=leaderboard,
internal=True,

View file

@ -58,7 +58,7 @@
}
.nonhuman {
opacity: 0.66;
opacity: .66;
}
.log {
@ -73,10 +73,6 @@
color: green;
}
.ago {
opacity: 0.66;
}
.datetime {
font-weight: 600;
margin: 1em 0;
@ -107,15 +103,9 @@
<div class="status-explanation">{{status.text}}</div>
<div class="level">{{status.level}}</div>
<div>
<strong>Since:</strong>
{% if last_change %}
{{ last_change['ts'].strftime("%c") }} - {{ last_change_natural}}
{% if status.level == 0 %}
({{last_change.leases | map(attribute='display') | join(', ')}})
{% endif %}
{% else %}
as far as I can tell?
{% endif %}
<strong>Since:</strong> {% if last_change %} {{last_change['ts'].strftime("%c")}} {% if
status.level == 0 %}({{last_change.leases | map(attribute='display') |
join(', ')}}){% endif %} {% else %} forever? {% endif %}
</div>
</div>
<h2>Current clients</h2>
@ -139,10 +129,7 @@
<table class="log">
{% for entry in log %}
<tr>
<td>
{{entry.ts.strftime("%c")}}
<span class="ago">({{entry.ts_natural}})</span>
</td>
<td>{{entry.ts.strftime("%c")}}</td>
<td>
{% if entry.state %}
<span class="log-in">IN</span>