Skip to content

Commit

Permalink
Merge pull request #388 from smk762/dev
Browse files Browse the repository at this point in the history
fix seednodes table
  • Loading branch information
smk762 authored Jun 7, 2024
2 parents fa1c084 + 648ecee commit a65874e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 42 deletions.
1 change: 1 addition & 0 deletions code/kmd_ntx_api/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand Down
81 changes: 43 additions & 38 deletions code/kmd_ntx_api/seednodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion code/kmd_ntx_stats/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down
3 changes: 0 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
version: '3.7'

# All Antara coins need these params
x-zcash-params-volume:
&zcash-params
type: bind
Expand Down

0 comments on commit a65874e

Please sign in to comment.