fablabbcn / smartcitizen-web

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

Kits not showing on the map - broken filters #407

Closed oscgonfer closed 4 years ago

oscgonfer commented 5 years ago

Expected behaviour

All kits should show when exploring the map in smartcitizen.me/kits

Actual behaviour

The kits (I believe ID > 10000) don't show up when exploring the map when exploring the map if you only visit the web.

Screen Shot 2019-09-18 at 15 53 35

If you visit a particular device (like this one) then they appear:

Screen Shot 2019-09-18 at 15 53 36
viktorsmari commented 5 years ago

@oscgonfer is this still an issue?

I think this is the same issue since the other day, some kind of caching?

Now I can see these devices.

Another example, I can also see devices 10.000 and 10.001, they are the ones in La Marina De Port:

2019-09-30_12-58-54

oscgonfer commented 5 years ago

Just checked the latest kits and they show while browsing. I don't know how long they take to appear though, it might be something to check?

viktorsmari commented 4 years ago

Here we can see for a new device, that one view has 1 more kits (20) vs (21)

All kits view has (20): 2019-10-09_09-19-11

But the new kits view has (21) 2019-10-09_09-19-02

viktorsmari commented 4 years ago

Looking at the developer console, I can see the id of the kit (10236) on both pages inside the world_map object.

/kits/ page: 2019-10-09_09-26-33

/kits/:id page: 2019-10-09_09-31-07

But it is not represented on the map. Notice also that the nr of the request is 1225 on one page, but 1226 on the other.

Update: Here we have a kit with id 10015 number 651: (on /kits/:id page) 2019-10-09_09-35-31

But here it is missing: (on /kits/ page) 2019-10-09_09-35-16

Which means that /kits/:id and /kits/ are not getting the same world_map ?

pral2a commented 4 years ago

Any news from this?

Can we discard this is an issue between world_map and fresh_world_map? In other words, this looks like a front-end issue only, right?

We are receiving around 2-3 user complains per week, that's why I'm writing a follow-up

viktorsmari commented 4 years ago

I am trying to narrow it down, and I think we can discard that the fresh_world_map is the reason. It is not called on either /kits/ or /kits/:id, so looks like we are not using it in this case.

The /kits/ endpoint already has the missing kits info in the data object on map initialize.

https://github.com/fablabbcn/smartcitizen-web/blob/cdc9b3f31fbf08442bcfe6f73bd1fe61b2629cf9/src/app/components/map/map.controller.js#L162-L166

When I console.log(data) (locally in line 167), I can see the missing kits, but they are not shown on the map when we visit /kits/ only on /kits/:id

In my newest example, multiple kits were missing in the same area, and all of them appeared on the /kits/:id page. So it is not just adding the missing kit to the list, because all missing kits are shown.

viktorsmari commented 4 years ago

I have narrowed it down to this function:

https://github.com/fablabbcn/smartcitizen-web/blob/cdc9b3f31fbf08442bcfe6f73bd1fe61b2629cf9/src/app/components/map/map.controller.js#L306-L316

The _.every will STOP when 1 of multiple labels does not exist, on the first false one. This means that the device would need to have ALL labels, instead of just any label to be allowed. A device with the label 'new' will therefore not be visible

This is why one shows the new kits, and the other does not. If the /:id parameter is present, it will not call updateMarkers()

https://github.com/fablabbcn/smartcitizen-web/blob/cdc9b3f31fbf08442bcfe6f73bd1fe61b2629cf9/src/app/components/map/map.controller.js#L184-L189

When you visit /:id of the kit, and you see it, the kit will go away when you apply filters.

In the following example: 2019-10-16_17-37-26 The second one will be added to the map, the first one not.

Also, this line: vm.selectedFilters = ['indoor', 'outdoor', 'online', 'offline'];

Should it also include 'new' ?