Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

What is the purpose of this article?

...

  1. Order sync and return sync happen depending on events.

  2. Whenever we get an update in DB ( either in case of order or in case of return), we sync that data and update their values in Algolia. ( either in case of order or in case of return) , we sync that data and update their values in Algolia.

  3. The problem we are facing is that we don't get the updates every day and DB does not get updated every day. Because of this, the last update remains as the latest status in Database.

For eg., Suppose the order scheduled to be RTS on 10th Jan, 2022 did not get picked up by the courier partner. As a result, there will be no update on DB about RTS getting delayed. On 11th Jan, 2022, order should be considered as " RTS delayed " with is a reason known. Meanwhile, in DB, update of 10th Jan or 9th Jan will be visible (i.e.,previous update) as RTS did not happen on expected date. So it's status couldn't be updated.

...

  1. v2/orders/algolia/sync/rts API will insert the records in the database with status as 0 and create a Task in Cloud Task orderSyncTrigger.

  2. Once a task is created in orderSyncTrigger, the task queue will hit the orderSyncTrigger API v2/orders/algolia/sync/rts/update.

  3. The orderSycnTrigger API will query the database and fetch the RTS Delayed data for last two days from order_returns_tags table. 3.1. If the numbers of RTS Delayed data fetched is 0 then simply return meaning, the cron is not needed to be run. 3.2. If the numbers of RTS Delayed data fetched is greater than 0 :- a) Run a query in database to fetch the pickup capacity of each order b) if picking capacity has exceeded for the day order was created then check in Database if was_unfulliable = 1 or was_unhold = 1 or or not. c) If true, then set delay reason remains empty and set SLA tag as “SLA Not Applicable”. d) If false then set delay reason as “Overcapoacity at FC” and SLA tag remains empty.

  4. Save all the RTS Delayed data fetched for last two days in Algolia.

  5. Update database and set status as 1 ie., is_rts_sync = 1 for the values fetched meaning that these data have been checked through the cron.