Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add feature to update duration #71

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions flomo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,14 @@ def delete(session_ids: Tuple):
@click.argument("session_id")
@click.option("-t", "--tag", help="Session Tag")
@click.option("-n", "--name", help="Session Name")
def update(session_id: str, tag: str | None, name: str | None):
@click.option("-d", "--duration", help="Total Duration")
def update(session_id: str, tag: str | None, name: str | None, duration: str | None):
"""
Update session data.
"""
try:
db = tracker.Tracker()
db.update_session(session_id, tag, name)
db.update_session(session_id, tag, name, duration)
db.conn.close()
except (
errors.DBFileNotFoundError,
Expand Down
7 changes: 6 additions & 1 deletion flomo/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def delete_session(self, session_ids: Tuple[str] | Tuple):
)
self.conn.commit()

def update_session(self, session_id: str, tag: str | None, name: str | None):
def update_session(self, session_id: str, tag: str | None, name: str | None, duration: str | None):
if not self.get_session(session_id):
raise errors.NoSessionError(session_id)

Expand All @@ -106,6 +106,11 @@ def update_session(self, session_id: str, tag: str | None, name: str | None):
"UPDATE sessions SET name = ? WHERE id = ?", (name, session_id)
)
print(f'Name updated to "{name}" for session {session_id}')
if duration:
self.cursor.execute(
"UPDATE sessions SET total_time = ? WHERE id = ?", (duration, session_id)
)
print(f'Duration updated to "{duration}" for session {session_id}')
self.conn.commit()


Expand Down
Loading