diff --git a/code/kmd_ntx_api/helper.py b/code/kmd_ntx_api/helper.py index 79f6c59..0078d11 100644 --- a/code/kmd_ntx_api/helper.py +++ b/code/kmd_ntx_api/helper.py @@ -11,6 +11,7 @@ from kmd_ntx_api.notary_seasons import get_seasons_info, get_season from kmd_ntx_api.cache_data import ecosystem_links_cache from kmd_ntx_api.logger import logger +from kmd_ntx_api.const import SINCE_INTERVALS diff --git a/code/kmd_ntx_api/seednodes.py b/code/kmd_ntx_api/seednodes.py index 2473159..9ab0cd9 100644 --- a/code/kmd_ntx_api/seednodes.py +++ b/code/kmd_ntx_api/seednodes.py @@ -12,6 +12,8 @@ from kmd_ntx_api.cache_data import version_timespans_cache from kmd_ntx_api.const import SINCE_INTERVALS from kmd_ntx_api.query import get_seednode_version_stats_data +from kmd_ntx_api.logger import logger + def seednode_version_context(request): active_version = " & ".join(get_active_mm2_versions(time.time())) @@ -103,46 +105,49 @@ def get_seednode_version_date_table(request): def get_seednode_version_month_table(request): - season = get_page_season(request) - year = get_or_none(request, "year", dt.now(timezone.utc).timestamp().year) - month = get_or_none(request, "month", dt.now(timezone.utc).timestamp().month) - start, end, last_day = get_month_epoch_range(year, month) - notary_list = get_notary_list(season) - default_scores = prepopulate_seednode_version_month(notary_list) - day_headers = list(default_scores.keys()) - day_headers.sort() - table_headers = ["Notary"] + day_headers + ["Total"] - data = get_seednode_version_stats_data(start=start, end=end).values() - for item in data: - notary = item["name"] - if notary in notary_list: - score = item["score"] - if score == 0.2: - date, _ = date_hour(item["timestamp"]).split(" ") - day = date.split("/")[1] - default_scores[day][notary]["score"] += score - if item["version"] not in default_scores[day][notary]["versions"]: - default_scores[day][notary]["versions"].append(item["version"]) - table_data = [] - for notary in notary_list: - notary_row = {"Notary": notary} - total = 0 - for day in day_headers: - total += default_scores[day][notary]["score"] + try: + season = get_page_season(request) + year = get_or_none(request, "year", dt.now(timezone.utc).year) + month = get_or_none(request, "month", dt.now(timezone.utc).month) + start, end, last_day = get_month_epoch_range(year, month) + notary_list = get_notary_list(season) + default_scores = prepopulate_seednode_version_month(notary_list) + day_headers = list(default_scores.keys()) + day_headers.sort() + table_headers = ["Notary"] + day_headers + ["Total"] + data = get_seednode_version_stats_data(start=start, end=end).values() + for item in data: + notary = item["name"] + if notary in notary_list: + score = item["score"] + if score == 0.2: + date, _ = date_hour(item["timestamp"]).split(" ") + day = date.split("/")[1] + default_scores[day][notary]["score"] += score + if item["version"] not in default_scores[day][notary]["versions"]: + default_scores[day][notary]["versions"].append(item["version"]) + table_data = [] + for notary in notary_list: + notary_row = {"Notary": notary} + total = 0 + for day in day_headers: + total += default_scores[day][notary]["score"] + notary_row.update({ + day: default_scores[day][notary]["score"] + }) notary_row.update({ - day: default_scores[day][notary]["score"] + "Total": round(total,1) }) - notary_row.update({ - "Total": round(total,1) - }) - table_data.append(notary_row) - return { - "date_ts": dt.utcfromtimestamp(end).strftime('%m-%Y'), - "date": dt.utcfromtimestamp(end).strftime('%b %Y'), - "headers": table_headers, - "table_data": table_data, - "scores": default_scores - } + table_data.append(notary_row) + return { + "date_ts": dt.utcfromtimestamp(end).strftime('%m-%Y'), + "date": dt.utcfromtimestamp(end).strftime('%b %Y'), + "headers": table_headers, + "table_data": table_data, + "scores": default_scores + } + except Exception as e: + logger.error(e) def get_seednode_version_score_total(request, season=None, start=None, end=None): if not season: diff --git a/code/kmd_ntx_stats/settings/dev.py b/code/kmd_ntx_stats/settings/dev.py index 752e037..afdea51 100644 --- a/code/kmd_ntx_stats/settings/dev.py +++ b/code/kmd_ntx_stats/settings/dev.py @@ -5,7 +5,7 @@ SECRET_KEY = os.getenv("SECRET_KEY") # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = False +DEBUG = True INSTALLED_APPS += ['debug_toolbar'] MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware'] diff --git a/docker-compose.yml b/docker-compose.yml index 68d7af3..887445d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,3 @@ -version: '3.7' - -# All Antara coins need these params x-zcash-params-volume: &zcash-params type: bind