def status(): # Make sure the database is reachable and that # it received some data in the last 24 hours now = time.time() then = now - (24*60*60) count = db.count_raw_data(then, now) if count == 0: return "No data in last 24 hours", 503 return "OK", 200
def index(): if request.args or 'formdata' not in session: session['formdata'] = request.args form = forms.PeriodForm(formdata=session['formdata']) form.validate() start = form.get_start() end = form.get_end() raw = db.count_raw_data(start, end) invalid = db.count_invalid_data(start, end) errors = db.count_planner_errors(start, end) planner_stats = db.get_planner_stats(start, end) dagman_stats = db.get_dagman_stats(start, end) downloads = db.count_downloads(start, end) table_args = { "limit" : 5, "offset" : 0, "start_time" : start, "end_time" : end } # These count variables are just dummies to get the top_hosts and top_domains totalCount, filterCount, top_hosts = db.get_top_hosts(**table_args) totalCount, filterCount, top_domains = db.get_top_domains(**table_args) return render_template('index.html', raw=raw, invalid=invalid, planner_errors=errors, planner_stats=planner_stats, dagman_stats=dagman_stats, top_hosts=top_hosts, top_domains=top_domains, downloads=downloads, form=form)