Forecasting inventory with API workflows

I’m looking to forecast predicted rental inventory on hand for the next 365 days and send an alert if its low using an API workflow.

I am currently using a repeating group calendar to display the quantity on hand for each day and it works well. For the repeating group I use the database query do a search for things:filter [advanced:current thing:date range contains current cell’s date point] :count

This gives me a number of expected items on hand for each day.

This works relatively swiftly for a repeating group and takes a second or so to run and display. I can leaf through the next 12 months without delay. In an API workflow, however, my options for recursive lookups for 365 days into the future seem a bit more cumbersome, slow and resource intensive. Is there a way to achieve a faster result using something like the Data API? Or another method I have not considered?

I’ve been experimenting with this a bit further. If I want to do an inventory count for each day in the next 365 days, it still seems as though I must launch 365 workflows to do so – either recursively or in parallel. There is a LOT of overhead tied up in launching a new workflow and running a separate DB query the DB and evaluating the expression this way.

The fastest I’ve been able to achieve is to launch these 365 workflows in parallel. Beforehand, I created a new thing type dateThing and 365 dateThings with a date that corresponds to a calendar date in the next year. I then did a search for list of dateThing’s date and ran an API workflow on the list of returned dates.

So far this has yielded the best result I’ve been able to achieve server-side for this lookup – about 4 minutes at 100% CPU utilization. I could conceivably run this as an overnight job, but this seems silly and I have hopes of introducing other similarly-complex queries as well as something that may be semi-real time.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.