cms/app-client/mirage/serializers/geostat.js
author ymh <ymh.work@gmail.com>
Sat, 10 Jun 2017 08:33:03 +0200
changeset 532 1190ea937f2d
parent 319 78990a8a069b
child 537 d2e6ee099125
permissions -rw-r--r--
make things work after node 8, npm 5 migration. Migrate to lodash 4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
284
12448de16a63 Add mirage geostat files
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     1
import { JSONAPISerializer } from 'ember-cli-mirage';
12448de16a63 Add mirage geostat files
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     2
532
1190ea937f2d make things work after node 8, npm 5 migration. Migrate to lodash 4
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
     3
import _ from 'lodash';
284
12448de16a63 Add mirage geostat files
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     4
12448de16a63 Add mirage geostat files
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     5
export default JSONAPISerializer.extend({
12448de16a63 Add mirage geostat files
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     6
    serialize(response, request) {
12448de16a63 Add mirage geostat files
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     7
    	var map = response.models.find(map => map.id === request.queryParams['area']);
532
1190ea937f2d make things work after node 8, npm 5 migration. Migrate to lodash 4
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
     8
        return {'geostats': _(map && map.areas || {}).map((geostat) => { return [geostat.id, geostat.count];}).fromPairs().value()};
284
12448de16a63 Add mirage geostat files
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     9
    }
12448de16a63 Add mirage geostat files
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    10
});