Skip to content

Commit

Permalink
Fix SQL creation error when ending active timer
Browse files Browse the repository at this point in the history
fixes #8 #9
  • Loading branch information
unode committed Jun 14, 2023
1 parent fa05435 commit fde04b8
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions polypomo
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,22 @@ class Status:
self.timer = Timer(self.worktime)

def save(self):
with setup_conn(self.saveto) as conn:
if self.active:
conn.execute(
"INSERT INTO sessions VALUES (date('now'), time('now'), NULL)"
)
else:
conn.execute(
"""UPDATE sessions
SET stop = time('now')
WHERE start IN (
SELECT start FROM sessions
ORDER BY start DESC
LIMIT 1)
"""
)
if self.saveto:
with setup_conn(self.saveto) as conn:
if self.active:
conn.execute(
"INSERT INTO sessions VALUES (date('now'), time('now'), NULL)"
)
else:
conn.execute(
"""UPDATE sessions
SET stop = time('now')
WHERE start IN (
SELECT start FROM sessions
ORDER BY start DESC
LIMIT 1)
"""
)


@contextmanager
Expand Down

0 comments on commit fde04b8

Please sign in to comment.