Skip to content

Commit

Permalink
fix month duplication possibility bug, ui cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tensorturtle committed Nov 30, 2024
1 parent 2511dde commit 344ba6b
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 23 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.1"
version = "0.2.2"
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/did.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ def did(args, db):
print("Start a new day: [green bold]fob gm[/green bold]")
return
else:
print("[green]Checklist updated.[/green] See overview: [cyan]fob sup[/cyan]")
print("[green]Checklist updated.[/green] See overview: [cyan][bold]fob sup[/cyan][/bold]")
9 changes: 5 additions & 4 deletions src/fob/commands/didnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ def didnt(args: Namespace, db: TinyDBWrapper):
print("Consider running: [cyan][bold]fob new_month[/cyan][/bold] if you want to reset the block allocations for this month.")
return

# show user today's checklist
# also is a guard for: there are blocks assigned to this day (it could be that right before the first day of the month, the checklist is empty.)
display_checklist(args, db)
# guard for: there are blocks assigned to this day (it could be that right before the first day of the month, the checklist is empty.)
if len(data['checklist']) == 0:
print("[red][bold]Error: No blocks assigned to today. Run [cyan][bold]fob gm[/cyan][/bold] to assign blocks to today.[/red][/bold]")
return

# ask user which number they want to convert to buffer block
try:
Expand Down Expand Up @@ -92,7 +93,7 @@ def didnt(args: Namespace, db: TinyDBWrapper):

# print success message
display_checklist(args, db)
print(f"[green][bold]Block {num_to_convert} converted to Buffer block successfully.[/green][/bold]")
print(f"[green]Block {num_to_convert} converted to Buffer block.[/green] See overview: [cyan][bold]fob sup[/cyan][/bold]")

except ValueError:
print("[red][bold]Please enter a number that corresponds to the checklist item[/red][/bold]")
Expand Down
14 changes: 4 additions & 10 deletions src/fob/commands/gm.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ def gm(args: Namespace, db: TinyDBWrapper) -> None:
print("[bold]Today's Checklist:[/bold]")
display_checklist(args, db)

print("Next commands: [cyan][bold]fob sup[/cyan][/bold] to see the above overviews again.")
print("[green][bold]fob did (number) [/green][/bold] to mark a block as done.")
print("[green]New day started.[/green]")
print("See overview: [cyan][bold]fob sup[/cyan][/bold]")
print("Mark a block as done: [green][bold]fob did <number>[/green][/bold]")
print("Convert a block to Buffer: [cyan][bold]fob didnt <number>[/cyan][/bold]")


def new_day(args: Namespace, db: TinyDBWrapper, data) -> None:
Expand Down Expand Up @@ -126,12 +128,6 @@ def new_day(args: Namespace, db: TinyDBWrapper, data) -> None:
print("Database updated successfully.")
print(Panel(Pretty(db.search(q.year == today.year and q.month == today.month))))

# also create a 'today' entry (for day overview) with the newly assigned blocks
# today_data = {
# "today": today_areas,
# }
# db.update({"today": today_areas}, None)

checklist = dict()
i = 0
for area_name, blocks in today_areas.items():
Expand All @@ -145,5 +141,3 @@ def new_day(args: Namespace, db: TinyDBWrapper, data) -> None:
if args.debug:
print("Today's data:")
print(Panel(Pretty(checklist)))

# updated checklist
10 changes: 6 additions & 4 deletions src/fob/commands/new_month.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from rich import print
from rich.table import Table
from rich.console import Console
from tinydb import where, Query

from fob.db import TinyDBWrapper
from fob.db import MonthBlockData
Expand All @@ -18,7 +19,7 @@ def new_month(args: Namespace, db: TinyDBWrapper) -> None:
if result is not None:
write_new_month(result, db)
print("\n[green]New month successfully created![/green]")
print("Next commands: [green bold]fob gm[/green bold] - Start your day with the good morning command.")
print("Start your day: [green bold]fob gm[/green bold]")

def write_new_month(data: MonthBlockData, db: TinyDBWrapper) -> None:
areas = {}
Expand All @@ -28,15 +29,16 @@ def write_new_month(data: MonthBlockData, db: TinyDBWrapper) -> None:
"completed": 0,
}

#!TODO - Add a check to see if the year-month already exists
db.insert({
# Overwrite the existing month data (shouldn't happen but avoids duplicates)
q = Query()
db.update({
"year": data.year,
"month": data.month,
"work_days_allocated": data.work_days_allocated,
"work_days_completed": 0,
"blocks_per_day": data.blocks_per_day,
"areas": areas,
})
}, q.year == data.year and q.month == data.month)

def loop_until_user_happy(args: Namespace) -> MonthBlockData | None:
user_is_happy = False
Expand Down
2 changes: 1 addition & 1 deletion src/fob/commands/reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ def reset(args: Namespace, db: TinyDBWrapper) -> None:
except FileNotFoundError:
pass

print("\nNext: [green bold]fob new_month[/green bold]: Start a new month (creates a new database)")
print("\nStart a new month: [green bold]fob new_month[/green bold]")
3 changes: 2 additions & 1 deletion src/fob/commands/sup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ def sup(args: Namespace, db: TinyDBWrapper) -> None:
'''
month_overview(args, db)
display_checklist(args, db)
print("Next commands: [green][bold]fob did (number)[/green][/bold] check off today's blocks.")
print("Mark a block as done: [green][bold]fob did <number>[/green][/bold]")
print("Convert a block to Buffer: [cyan][bold]fob didnt <number>[/cyan][/bold]")
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,1)
return (0,2,2)

def get_db_path(args: Namespace) -> Path:
'''
Expand Down

0 comments on commit 344ba6b

Please sign in to comment.