Universalis-FFXIV / Universalis

A crowdsourced market board API for FFXIV.
https://universalis.app/
MIT License
167 stars 23 forks source link

Set `/api/v{version}/history` to default `entriesWithin=604800` #1177

Closed cohenaj194 closed 7 months ago

cohenaj194 commented 7 months ago

I noticed most of the 50X errors are currently coming from requests on specific items with many entries coming every few seconds:

http://universalis.app/api/history/Japan/29000?entries=4800

By default this searches all available history returning a very large amount of data. A simple method to reducing the 50X responses and ease the load on the system is to implement a default time range when none is specified so that every request will be for entriesWithin=604800 (i.e. one week) unless the user specifically sets entriesWithin to a custom value. For example the following request would result in far less data and be easier on the system:

http://universalis.app/api/history/Japan/29000?entries=4800&entriesWithin=604800

cohenaj194 commented 7 months ago

I believe this might be a very simple fix changing entries from -1 (assuming that is the beginning of universalis history) to 7 days 604800L

https://github.com/Universalis-FFXIV/Universalis/blob/v2/src/Universalis.Application/Controllers/V1/HistoryController.cs#L87