Skip to content

Commit

Permalink
fix: stats on prev to start attack and flags
Browse files Browse the repository at this point in the history
  • Loading branch information
domysh committed Jun 21, 2024
1 parent 193469d commit 04f654d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion backend/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async def write_on_db():
await set_db_stats(g.stats)

def calc_tick(time:datetime):
return abs(math.floor((time - g.stats["start_time"]).total_seconds() / g.stats["tick_duration"])) + 1
return math.floor((time - g.stats["start_time"]).total_seconds() / g.stats["tick_duration"]) + 1

def calc_tick_range(tick:int):
return (g.stats["start_time"] + timedelta(seconds=(tick-1)*g.stats["tick_duration"]), g.stats["start_time"] + timedelta(seconds=tick*g.stats["tick_duration"]))
Expand All @@ -86,6 +86,8 @@ def add_stats(attack: AttackExecution, action: callable):

#Adding missing ticks
tick = calc_tick(attack.recieved_at)
if tick <= 0: return #skip data before start time

if tick-len(g.stats["ticks"]) > 0:
old_tick = len(g.stats["ticks"])
for i in range(tick-len(g.stats["ticks"])):
Expand Down

0 comments on commit 04f654d

Please sign in to comment.