osm-fr / osmose-frontend

Part of osmose that shows results on the website http://osmose.openstreetmap.fr
GNU General Public License v3.0
41 stars 38 forks source link

Page runs out of memory due to too many classes #438

Closed Famlam closed 1 year ago

Famlam commented 1 year ago

famlam: Is it just my browser or does this page actually always run out of memory? https://osmose.openstreetmap.fr/nl/issues/open?item=9015 (the OpenRailwayMap issue list)

frodrigo: Yes I have the same issue. I think it is beacause there lot of classes for this item for one country it works

Possible solution idea: limit the number of "classes x countries" loaded by default to for example 5000, similar to the issue list (which by default only loads 50 issues unless you explicitly click a button to load more)? If the server does the pre-sorting to get the ones with the most issues, you'll still see the most useful ones.

OpenRailwayMap has 42 classes; Osmose has about 1200 countries/regions, so the total number of rows to be loaded would be over 50k

Another option would be to disable this specific plugin in the backend in countries without a railway network , but this would only exclude about 45 countries https://en.wikipedia.org/wiki/List_of_countries_by_rail_transport_network_size#Countries_currently_without_a_rail_network

jocelynj commented 1 year ago

Possible solution idea: limit the number of "classes x countries"

This is a good idea, and we already do this to limit the number of errors shown on this page.

jocelynj commented 1 year ago

@frodrigo , would this patch work?

--- a/web_api/issues.py
+++ b/web_api/issues.py
@@ -64,7 +64,7 @@ async def index(
     errors_groups: List[Dict[str, Any]] = []
     total = 0
     if params.item:
-        params.limit = None
+        params.limit = min(params.limit, 1000)
         errors_groups = await query._count(
             db,
             params,
frodrigo commented 1 year ago

No, params.limit is already used for the issues list.

frodrigo commented 1 year ago

Fixed browser side.

Famlam commented 1 year ago

Great 😊