def current_status(): load = "%.2f %.2f %.2f" % os.getloadavg() listen_count = _ts.get_total_listen_count() try: user_count = format(int(_get_user_count()), ',d') except DatabaseException as e: user_count = 'Unknown' listen_counts_per_day: List[dict] = [] for delta in range(2): try: day = datetime.utcnow() - relativedelta(days=delta) day_listen_count = _redis.get_listen_count_for_day(day) except: current_app.logger.error("Could not get %s listen count from redis", day.strftime('%Y-%m-%d'), exc_info=True) day_listen_count = None listen_counts_per_day.append({ "date": day.strftime('%Y-%m-%d'), "listen_count": format(day_listen_count, ',d') if day_listen_count else "0", "label": "today" if delta == 0 else "yesterday", }) return render_template( "index/current-status.html", load=load, listen_count=format(int(listen_count), ",d") if listen_count else "0", user_count=user_count, listen_counts_per_day=listen_counts_per_day, )
def index(): # get total listen count try: listen_count = _ts.get_total_listen_count() except Exception as e: current_app.logger.error( 'Error while trying to get total listen count: %s', str(e)) listen_count = None return render_template( "index/index.html", listen_count=listen_count, )
def index(): if _ts: try: listen_count = _ts.get_total_listen_count() user_count = format(int(_get_user_count()), ',d') except Exception as e: current_app.logger.error( 'Error while trying to get total listen count: %s', str(e)) listen_count = None user_count = 'Unknown' else: listen_count = None user_count = 'Unknown' return render_template( "index/index.html", listen_count=format(int(listen_count), ",d") if listen_count else "0", user_count=user_count, )