Skip to content

Commit

Permalink
fixing some wierd bug!
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonak-Adipta-Kalita committed Jul 14, 2024
1 parent eae26f9 commit bb845eb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions flomo/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ def __init__(self):

def create_table(self):
self.cursor.execute(
"CREATE TABLE IF NOT EXISTS sessions (id FLOAT PRIMARY KEY, date_time, tag TEXT, name TEXT, total_time TEXT)"
"CREATE TABLE IF NOT EXISTS sessions (id FLOAT PRIMARY KEY, date_time TEXT, tag TEXT, name TEXT, total_time TEXT)"
)
self.conn.commit()

def create_session(
self, tag: str, name: str, start_time: datetime.datetime
) -> float:
session_id = start_time.timestamp()
session_id = start_time.timestamp() % 1000000
self.cursor.execute(
"INSERT INTO sessions (id, date_time, tag, name) VALUES (?, ?, ?, ?)",
(session_id, start_time.strftime("%Y-%m-%d %H:%M:%S"), tag, name),
Expand All @@ -32,7 +32,10 @@ def create_session(
return session_id

def update_session(self, session_id: float, end_time: datetime.datetime):
total_time = end_time - datetime.datetime.fromtimestamp(session_id)
date_time = self.get_session(session_id)[1]
total_time = end_time - datetime.datetime.strptime(
date_time, "%Y-%m-%d %H:%M:%S"
)
self.cursor.execute(
"UPDATE sessions SET total_time = ? WHERE id = ?",
(
Expand Down

0 comments on commit bb845eb

Please sign in to comment.