bocoup / blocks-capacity-planner

An airtable block for matching supply to demand in an airtable base.
MIT License
3 stars 3 forks source link

Matching restaurants to recipients in the planning block doesn't work #55

Open jesarshah opened 4 years ago

jesarshah commented 4 years ago

Right now, when you have restaurants and recipients in the planning block set up, there is an error thrown every time when you try to match (by drag and drop). Not sure how to debug this issue.

jugglinmike commented 4 years ago

Thanks for the report, @jesarshah! This error was caused by a formatting issue in the input data. It can be resolved by correcting the data in the table, and I've done that. Everything ought to be working as intended now.

That said, the error message was not very helpful, so I've also submitted a patch intended to describe what's going wrong if this ever happens again--see gh-56.

Here's a little more background.

We initially set up the table with all the delivery times we thought we'd need. We created one row for every hour of every day of the week (e.g. "Wednesday @ 19:00"). It looks like folks needed to set delivery times at the half-hours because the table now has a handful of additional rows with times like "Monday @ 19:30". Although we didn't expect this extension, it generally seems to work. The problem is that two of the new times used a single-digit for the hour ("Monday @ 9:30" and "Wednesday @ 9:30"), and this threw off the application. Maybe the Block should be more forgiving for the way people might express times, but since we didn't plan on that data being extended, we didn't invest the time there. We still could, but far easier in the short term is to report the problem immediately (i.e. when the Block starts, as opposed to when a new assignment is created) and with a more specific explanation.

Here are some thoughts on how to diagnose problems like these.

The error reported when attempting to schedule a delivery looked like this:

Error: Can't create records: invalid cell value for field 'Delivery Scheduled'.
Invalid date
    at Mutations._assertMutationIsValid (https://localhost:9000/__runFrame/bundle.js:6711:55)
    at Mutations.applyMutationAsync$ (https://localhost:9000/__runFrame/bundle.js:6413:20)
    at tryCatch (https://localhost:9000/__runFrame/bundle.js:87614:40)
    at Generator.invoke [as _invoke] (https://localhost:9000/__runFrame/bundle.js:87843:22)
    at Generator.prototype.<computed> [as next] (https://localhost:9000/__runFrame/bundle.js:87666:21)
    at tryCatch (https://localhost:9000/__runFrame/bundle.js:87614:40)
    at invoke (https://localhost:9000/__runFrame/bundle.js:87704:20)
    at https://localhost:9000/__runFrame/bundle.js:87739:11
    at new Promise (<anonymous>)
    at callInvokeWithMethodAndArg (https://localhost:9000/__runFrame/bundle.js:87738:16)

There's a lot of technical detail there, but the most important part is the first two lines. That's saying that the "Delivery Scheduled" field couldn't be set because the date was invalid. This gives a clue about where to look next: which entity is responsible for defining delivery times? That's the hospital (or the "recipient" in more generic terms), so the error had to originate from the hospital data.