feat: Migration v0 to v1.
Move 'tasklist' table to 'taskslist' for compatibility. Add migration sql script. Add 'taskslist_info' view. Add 'completed_in' to tasks.
This commit is contained in:
12
tasklist.py
12
tasklist.py
@@ -127,24 +127,28 @@ class Tasklist:
|
||||
async def unset_now(self):
|
||||
# Unset the current task and update the duration correctly
|
||||
# Does not put the current task on the plan
|
||||
# TODO: Transaction
|
||||
current = self.get_current()
|
||||
if current is not None:
|
||||
now = utc_now()
|
||||
assert current.is_running or (current.last_started is None)
|
||||
if current.is_running:
|
||||
if current.last_started is not None:
|
||||
duration = (now - current.last_started).total_seconds()
|
||||
duration += current.duration
|
||||
await self.data.tasklist.update_where(taskid=current.taskid).set(duration=duration)
|
||||
await self.data.nowlist.delete_where(taskid=current.taskid)
|
||||
await self.on_update()
|
||||
|
||||
async def complete_tasks(self, *taskids) -> list[TaskInfo]:
|
||||
async def complete_tasks(self, *taskids, communityid: int|None = None) -> list[TaskInfo]:
|
||||
# Remove any tasks which are already complete
|
||||
# TODO: Transaction
|
||||
# TODO: Uncomplete tasks
|
||||
taskids = [id for id in taskids if not self.id_tasks[id].is_complete]
|
||||
if taskids:
|
||||
now = utc_now()
|
||||
await self.data.tasklist.update_where(taskid=taskids).set(completed_at=now)
|
||||
await self.data.tasklist.update_where(taskid=taskids).set(
|
||||
completed_at=now,
|
||||
completed_in=communityid
|
||||
)
|
||||
if self.current in taskids:
|
||||
current = self.get_current()
|
||||
assert current is not None
|
||||
|
||||
Reference in New Issue
Block a user