api icon indicating copy to clipboard operation
api copied to clipboard

Filter[since] on settledAt

Open bentwonk opened this issue 3 years ago • 3 comments
trafficstars

When getting the transactions using the filter[since] is is possible to filter on the settledAt date, not createdAt as I am only interested once a transaction has been settled.

bentwonk avatar Jan 07 '22 03:01 bentwonk

Hi @bentwonk,

I'm not sure if this will help you or not, but you can use filter[status] to get only the settled transactions, but filter[since] would still search on the createdAt, yep. Up rarely exposes the times at which transactions settle and favours keeping transactions ordered as they first occurred.

d11wtq avatar Jan 07 '22 03:01 d11wtq

Thanks, but i don't think that will help, a createdAt transaction is in a nebulas state and may never be settled, so I don't want to account for it until settlement.

I want to automatically pull down the transactions aprox weekly, I don't want to pull down duplicates, so was using the date to slice the data, but currently being limited to filtering on createsAt it's possible to get a transaction that was created but not settled in one slice, and it will not appear in the next weekly slice. I am thinking my solution is to store all the transactions, then test each HELD transaction against the api to see if its been settled since the original data was grabbed. Seems messy compared to just filtering on settledAt :-(

bentwonk avatar Jan 07 '22 03:01 bentwonk

Perhaps it may be sufficient to add ?sort=-createdAt (default), ?sort=settledAt (?sort=-settledAt for descending order, as per JSON:API). The filter[since] and filter[until] parameters would operate on the basis of the sort order.

The only question that then arises is what to do about null values for settledAt in the case of pending transactions. Likely the best option would be to surface them either always at the start or always at the end, or perhaps make it such that using ?sort=settledAt implies ?filter[status]=SETTLED (I think I prefer keeping it explicit though).

d11wtq avatar Jan 13 '22 21:01 d11wtq