fablabbcn/smartcitizen-web

Kits not showing on the map - broken filters

Closed this issue · 7 comments

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

@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

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?

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

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 ?

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

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.

$q.all([device.getAllDevices($stateParams.reloadMap), device.createKitBlueprints()])
.then(function(data){
data = data[0];

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.

I have narrowed it down to this function:

function filterMarkersByLabel(tmpMarkers) {
return tmpMarkers.filter(function(marker) {
var labels = marker.myData.labels;
if (labels.length === 0 && vm.selectedFilters.length !== 0){
return false;
}
return _.every(labels, function(label) {
return _.includes(vm.selectedFilters, label);
});
});
}

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()

if($state.params.id && markersByIndex[parseInt($state.params.id)]){
focusedMarkerID = markersByIndex[parseInt($state.params.id)]
.myData.id;
} else {
updateMarkers();
}

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' ?