swent-group10 / polyfit

0 stars 1 forks source link

Feature/map/improvement #337

Closed Neb1010 closed 3 months ago

Neb1010 commented 3 months ago

Improvement of the Map

What's new

Front end

image

Back end

File in comment

This file is in comment because if we don't have enough code coverage I will try to fix these tests, as the implementation has changed they are not up to date

What could be improved for a V2

Initially, the update was done dynamically, but it could happen that the nearest posts would remain displayed even if they were outside the circle. Imagine three layers: layer 1 with 0 posts, layer 2 with 1 post, and layer 3 with 2 posts. If the radius is larger than layer 3, the map will display 3 posts. By reducing the radius, we will be smaller than layer 3, so it will query only the posts from layer 2 and layer 1. However, if we reduce the radius quickly enough to have only layer 1 in the circle, since there are no posts, the query response will be faster than that of layer 3 to 2, resulting in the final query response from 3 to 2.

I tried several ways to solve this small problem, such as using locks or CAS (Compare and Swap). None were very convincing, even though some solutions seemed to reduce the probability of encountering this scenario. I felt more like I was doing code tinkering that depended on the speed of Firebase, and the solution wouldn't scale with the number of posts in the second layer.

So currently, the update is no longer done dynamically to avoid this scenario. I find it a bit less nice, but for a V2, it could be cool to make it dynamic again.

Here a small video of the problem in a dynamically fashion Vidéo sans titre ‐ Réalisée avec Clipchamp

sonarcloud[bot] commented 3 months ago

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
25.1% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud