plainblack / TGCv

TGC built on ving instead of wing
https://plainblack.github.io/ving/
0 stars 0 forks source link

Find out why disposing HardwareTasks breaks navigation #6

Closed perlDreamer closed 4 weeks ago

perlDreamer commented 2 months ago

Currently commented out on HardwareTickets and HardwareSchedule

perlDreamer commented 2 months ago

Added console logging after every step of useVingRecord:dispose, everything logged. Added console logging in maintenanceticket:index.mjs inside onBeforeRouteLeave, it starts but never finishes. No errors are thrown.

useVingKind dispose iterates over records, calling dispose on each of them. For Tasks, there are 242 records that need to be disposed, but it silently dies when trying to call dispose on task 71. That's probably on the call to this.$reset. I wrapped it in a try/catch block and this is that it spews:

Screenshot 2024-09-09 at 12 55 29 PM

Not sure why this isn't being normally logged? But it lets everything finish.

perlDreamer commented 2 months ago

More information.

There are 242 records in the database. The page says that there are 242 records to be cleaned up. But Record 67 and 75 both seem to have the same Pinia id HardwareTaskvEHd5pX. I bet you can't safely call $reset on an object twice in Pinia.

Record 67
useVingRecord.mjs:201 HardwareTaskvEHd5pX
useVingKind.mjs:226 Record 68
useVingRecord.mjs:201 HardwareTaskvDfbKKX
useVingKind.mjs:226 Record 69
useVingRecord.mjs:201 HardwareTaskvETONuq
useVingKind.mjs:226 Record 70
useVingRecord.mjs:201 HardwareTaskvBdZOsQ
useVingKind.mjs:226 Record 71
useVingRecord.mjs:198 TypeError: Cannot convert undefined or null to object
    at assign (<anonymous>)
    at pinia.mjs:1336:17
    at Proxy.$patch (pinia.mjs:1304:13)
    at Proxy.$reset2 (pinia.mjs:1335:18)
    at Proxy.dispose (useVingRecord.mjs:197:28)
    at Proxy.<anonymous> (pinia.mjs:1380:30)
    at store.<computed> (pinia.mjs:935:50)
    at VingKind.dispose (useVingKind.mjs:228:20)
    at index.vue:156:22
    at vue-router.mjs:2066:56
useVingRecord.mjs:201 HardwareTaskvEHd5pX
perlDreamer commented 2 months ago

In the 242 records, that's the only duplicated record. I don't have an easy way to get all the records from the db to figure out which one is duplicated.

perlDreamer commented 1 month ago

We're missing 5689, one of the Lubricate tasks.

After looking at some data, this is the same problem as we had with MySQL with Wing. The tasks are coming out in description order, and many of the descriptions are duplicates. I don't know why it isn't happening more frequently.

The solution is to use the id as the default sort order, and if a sort order is requested, then id is appended to the end of that list.

perlDreamer commented 1 month ago

I'm wrong. The tasks are coming out in createdAt order, and because all the tasks are currently created programmtically, all the createdAt dates are all identical to the nearest second.

Working on a patch.

perlDreamer commented 1 month ago

@rizen

Patch: https://github.com/plainblack/ving/compare/main...db_sorting_duplicates

This is JS and Drizzle, so please give it the eyeball check.

perlDreamer commented 4 weeks ago

Fixed