Skip to content

Commit

Permalink
fix db upsert bug in new_month
Browse files Browse the repository at this point in the history
  • Loading branch information
tensorturtle committed Nov 30, 2024
1 parent 344ba6b commit 9895c9b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "fob"
# Remember to update the version number in 'utils/utils.py' manually also.
version = "0.2.2"
version = "0.2.3"
description = "Focus Blocks: Simple and elegant daily time management tool."
readme = "README.md"
authors = [{ name = "tensorturtle", email = "[email protected]" }]
Expand Down
2 changes: 1 addition & 1 deletion src/fob/commands/new_month.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def write_new_month(data: MonthBlockData, db: TinyDBWrapper) -> None:

# Overwrite the existing month data (shouldn't happen but avoids duplicates)
q = Query()
db.update({
db.upsert({
"year": data.year,
"month": data.month,
"work_days_allocated": data.work_days_allocated,
Expand Down
3 changes: 3 additions & 0 deletions src/fob/db/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ def insert(self, data):
# Insert a document (dictionary) into the database
return self.db.insert(data)

def upsert(self, fields, query):
return self.db.upsert(fields, query)

def all(self):
# Get all documents stored in the database
return self.db.all()
Expand Down
2 changes: 1 addition & 1 deletion src/fob/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from rich import print

def get_version_number() -> tuple[int, int, int]:
return (0,2,2)
return (0,2,3)

def get_db_path(args: Namespace) -> Path:
'''
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9895c9b

Please sign in to comment.