From c1e70576ce6c1d873a8294efaf8b153d62401c34 Mon Sep 17 00:00:00 2001 From: freeram Date: Fri, 5 Apr 2024 05:23:23 -0600 Subject: [PATCH] Fix idling timestamp, clean --- pomodorodiscord/src/frames/pomodoro_frame.py | 11 ++++------- pomodorodiscord/src/logic/richpresence.py | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/pomodorodiscord/src/frames/pomodoro_frame.py b/pomodorodiscord/src/frames/pomodoro_frame.py index 5c147d4..adf48de 100644 --- a/pomodorodiscord/src/frames/pomodoro_frame.py +++ b/pomodorodiscord/src/frames/pomodoro_frame.py @@ -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 @@ -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) @@ -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) @@ -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() diff --git a/pomodorodiscord/src/logic/richpresence.py b/pomodorodiscord/src/logic/richpresence.py index c26c3cc..543e80b 100644 --- a/pomodorodiscord/src/logic/richpresence.py +++ b/pomodorodiscord/src/logic/richpresence.py @@ -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):