fablabbcn / smartcitizen-web

The Smart Citizen Kit platform
https://smartcitizen.me
GNU Affero General Public License v3.0
13 stars 7 forks source link

Rate limits impede browsing of the web-app when not logged in or logged in as user without admin/researcher privileges #447

Closed timcowlishaw closed 7 months ago

timcowlishaw commented 8 months ago

Mentioned on fablabbcn/smartcitizen-api#166 - When i am browsing the webapp while not logged in as a researcher or admin (o sea, logged in as an unprivileged user or not logged in at all), requests to the API periodically return 429 (due to rate limiting) and data on the page is not loaded.

Screenshot 2023-10-26 at 08 31 02
timcowlishaw commented 8 months ago

Discussed with @oscgonfer - after further investigation this only happens on user pages with a large number of kits, eg @pral2a :

sc_dev=# select users.username, count(devices.id) from users left join devices on users.id = devices.owner_id group by users.username order by count(devices.id) desc limit 10;
       username        | count
-----------------------+-------
 john                  |  1312
 team                  |  1264
 pral2a                |   492
 AIRLAB-ISGlobal       |   274
 Unibo                 |   162
 Battirob              |    60
 natamyk               |    40
 AIRLAB_ISGlobal       |    32
 IAAC-Cristian_Rizzuti |    31
 vico                  |    28

... as it makes a request for each kit. However this is unnecessary, as the kits data already arrives in the /v0/users/x api request! @oscgonfer to change so that it uses the data that's already there, and we should be fine :-)

(#443 would also fix this, but would still be making unnecessary requests)

pral2a commented 8 months ago

See https://github.com/fablabbcn/smartcitizen-web/issues/443#issuecomment-1781054481 Thanks!

oscgonfer commented 7 months ago

https://github.com/fablabbcn/smartcitizen-web/pull/454