Skip to content

Commit

Permalink
Merge pull request #52 from MinaFoundation/create-bot-log-when-no-sub…
Browse files Browse the repository at this point in the history
…s-processed

PM-1592 Create bot log when no subs processed
  • Loading branch information
piotr-iohk authored May 8, 2024
2 parents d488d71 + 3a1bf18 commit 8bee574
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def init_database(ctx, batch_end_epoch=None, mins_ago=None, override_empty=False

if should_insert:
processing_time = 0
files_processed = 0
files_processed = -1 # -1 indicates that this is initialization
file_timestamps = datetime.fromtimestamp(batch_end_epoch, timezone.utc)
batch_start_epoch = batch_end_epoch

Expand Down
12 changes: 10 additions & 2 deletions uptime_service_validation/coordinator/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,16 @@ def process(db, state):
state.retry_batch()
return
else:
# new bot log id hasn't been created, so proceed with the old one
bot_log_id = state.batch.bot_log_id
# process_statehash_df not processed so new bot log id hasn't been created,
# creating a new bot log id entry with 0 submissions processed
values = (
0, # submissions processed
state.batch.end_time,
state.batch.start_time.timestamp(),
state.batch.end_time.timestamp(),
timer.duration.total_seconds(),
)
bot_log_id = db.create_bot_log(values)
logging.info("Finished processing data from table.")
try:
db.update_scoreboard(
Expand Down
2 changes: 1 addition & 1 deletion uptime_service_validation/coordinator/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def update_scoreboard(self, score_till_time, uptime_days=30):
, b_logs as(
select (count(1) ) as surveys
from bot_logs b , epochs e
where b.batch_start_epoch >= start_epoch and b.batch_end_epoch <= end_epoch and b.files_processed > 0
where b.batch_start_epoch >= start_epoch and b.batch_end_epoch <= end_epoch and b.files_processed > -1
)
, scores as (
select p.node_id, count(p.bot_log_id) bp_points
Expand Down

0 comments on commit 8bee574

Please sign in to comment.