Closed perlDreamer closed 4 weeks 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:
Not sure why this isn't being normally logged? But it lets everything finish.
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
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.
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.
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.
@rizen
Patch: https://github.com/plainblack/ving/compare/main...db_sorting_duplicates
This is JS and Drizzle, so please give it the eyeball check.
Fixed
Currently commented out on HardwareTickets and HardwareSchedule