Skip to content

Commit

Permalink
Fix idling timestamp, clean
Browse files Browse the repository at this point in the history
  • Loading branch information
jake158 committed Apr 5, 2024
1 parent 97c940d commit c1e7057
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions pomodorodiscord/src/frames/pomodoro_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def toggle_timer(self):
end_time = now + timedelta(seconds=self.remaining_time)
self.start_time_timestamp = now.timestamp()
self.end_time_timestamp = end_time.timestamp()
# For track_second()
# For tracking seconds studied by date
self.current_date = now.strftime("%Y-%m-%d")

self.running = not self.running
Expand All @@ -107,7 +107,6 @@ def update_timer(self):
self.remaining_time -= 1
if not self.break_running:
self.track_second()
self.seconds_studied += 1
minutes, seconds = divmod(self.remaining_time, 60)
self.timer_display.configure(text=f"{minutes:02d}:{seconds:02d}")
self.next_timer_update = self.after(1000, self.update_timer)
Expand All @@ -116,8 +115,8 @@ def update_timer(self):

def track_second(self):
current_date = self.current_date
self.seconds_studied += 1
data = load_data()

data['total_seconds_studied'] += 1
data['seconds_by_date'][current_date] = data['seconds_by_date'].get(current_date, 0) + 1
save_data(data)
Expand Down Expand Up @@ -160,16 +159,14 @@ def session_ended(self):

self.session_counter += 1

current_date = self.current_date
data = load_data()

data['total_pomodoro_sessions'] += 1
data['sessions_by_date'][current_date] = data['sessions_by_date'].get(current_date, 0) + 1
data['sessions_by_date'][self.current_date] = data['sessions_by_date'].get(self.current_date, 0) + 1
save_data(data)

if not was_break and self.auto_break_cycling:
if self.short_break_counter >= self.short_breaks_before_long:
self.short_break_counter = 0 # Reset counter when long break
self.short_break_counter = 0
self.long_break()
else:
self.short_break()
Expand Down
2 changes: 1 addition & 1 deletion pomodorodiscord/src/logic/richpresence.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def format_time(self, seconds_studied):
return f"{total_hours:.1f} hours"

def default_state(self):
self.update(state="Idling", details=None, start=datetime.now().timestamp(), large_image="graytomato",
self.update(state="Idling", details=None, start=self.launch_time, large_image="graytomato",
large_text="github.com/freeram/pomodoro-discord")

def running_state(self, session, start_time, end_time):
Expand Down

0 comments on commit c1e7057

Please sign in to comment.