Skip to content
Nick Frost edited this page May 4, 2017 · 2 revisions

Overview

This app looks at /var/log/seclab.out, and renders an SVG.

The SVG is served from https://thewhitehat.club/timecard.svg. It takes optional query parameters start and end. These are dates, in the format YYYY-MM-DD. For example, https://thewhitehat.club/timecard.svg?start=2017-04-06&end=2017-06-16 only includes statistics from Spring 2017.

Details

We'll use the term weekday-hour (eg. 2-3pm Wednesday). The basic algorithm is to loop through pairs of open and close timestamps, and increment the total count for each weekday-hour that range spans. If the lab opens or closes in the middle of an hour, only that fraction of the weekday-hour is added to the total. So the range 1:30-2:45pm Tuesday would increment the 1-2pm Tuesday counter by 0.5, and the 2-3pm Tuesday counter by 0.75.

To avoid redoing this computation on every request, we cache the weekday-hour totals, memoized by the date range for that count. So requesting the timecard for two different date ranges will create two different caches. The cache is invalidated if the log file's modification time is newer than the cache.

Clone this wiki locally