lib-cleanOrdersInProcessArray

?ordersInProcess

%tmpArray=%ordersInProcess

$ %tmpArray each(%arrayOrder)

%orderId=$.orderId %arrayOrder

calc %arrayOrderTimestamp=explode('_','%orderId')[1]

?arrayOrderTimestamp

%tmpArray=null

calc %oldness=%sys.timestamp-%arrayOrderTimestamp

?oldness>600

$[?(@.orderId=="%orderId")] %ordersInProcess remove()

%arrayOrder=null

?arrayOrderTimestamp=⚠️ Error

?arrayOrderTimestamp=0

  • First init for every user always remains: %ordersInProcess=[{"orderId":"skip_0","orderData":"orderData_stub"}]
  • If explode doesn't find element on required place, it returns ⚠️ Error #

Use ONLY text_timestamp format for orderId. It will protect from type mistakes in set function. Here i do logic basing on this. #

%oldness=null

%arrayOrderTimestamp=null

%orderId=null

go #

go #