jdhitsolutions / PSWorkItem

A PowerShell 7 module for managing work and personal tasks or to-do items. This module uses a SQLite database to store task and category information. The module is not a full-featured project management solution, but should be fine for personal needs. The module requires a 64-bit Windows or Linux platform.
MIT License
36 stars 5 forks source link

[Request]: Complete-PSWorkItem include original task id with archived task #7

Closed jbelina closed 1 year ago

jbelina commented 1 year ago

Describe the request

I ended up using the following in my own wrapper for Complete-PSWorkItem so that I could see both the new and old Task ID's when closing a task.

if ($ID) { "Completing Task(s)" | Write-Verbose $completed_tasks = { foreach ($taskid in $ID) { "Complete Task: $taskid" | Write-Debug Complete-PSWorkItem -ID $taskid @parameters | Select-Object -Property @{Name = 'OriginalTaskID'; Expression = { "$taskid" } }, Name, Description, Category, CompletedDate, @{Name = 'ClosedTaskID'; Expression = { "$($PSItem.ID)" } } } }

PowerShell version

7.2

Platform

Windows 11 Home

jdhitsolutions commented 1 year ago

This makes sense and is something I should have looked at harder when I started this. Currently, I'm using the ID as the key for the table. I'd have to restructure the archive table, which would be a breaking change. This will take some time to work out.

jdhitsolutions commented 1 year ago

One thing I could do that wouldn't be that hard is to add a property to the PSWorkItemArchive object to store the original ID. I can modify the format file to display it instead of the table ID. I can also add a parameter set to Get-PSWorkItemArchive to get the item by its original ID.

The biggest issue would be updating the database and table structure.

jbelina commented 1 year ago

I like that idea.

For now it's not really something I need, it's just nice to see when I'm choosing a task.

So, my wrapper works perfectly for me.

jdhitsolutions commented 1 year ago

I've been trying a few things, and maybe writing things out will help clarify the situation. The task object has a hidden property called taskID which is a GUID. The ID number of a PSWorkItem is the row number from the tasks table. When a task is completed, it is copied to the Archive table. At this point, when I get a completed task the ID number is a different row number because it is a different table.

I've been testing code where the archive table has an additional column called OriginalID. When a task is closed, I copy the original task id, i.e. the original row number, to this column.

The problem is that when I create a new task, it will have a row number identical to the last completed item. This means when I get completed items, I will have duplicate items with the same original id. To me, this makes this new table column meaningless. Getting a completed item by its original ID could return multiple entries.

I wonder if I could create a new PSWorkitem property and table column called tasknumber. I could use the rownumber for the value on new items. This property could be inherited by archived items. This would also require table updates. This has possibilities.

jdhitsolutions commented 1 year ago

The code I have now that seems to work copies the original ID to the ID for the archived item. I think I have this working in the current release.

jdhitsolutions commented 1 year ago

I think I have this resolved. If not, we can re-open the issue.