-
Notifications
You must be signed in to change notification settings - Fork 12
/
query.js
31 lines (30 loc) · 876 Bytes
/
query.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import moment from 'moment';
import { config } from './config';
export function query(changesetID) {
var url = `${config.osmBase}changeset/${changesetID}.json?include_discussion=true`;
var options = {
method: 'GET',
headers: { 'Content-Type': 'application/json' }
};
return fetch(url, options)
.then(r => r.json())
.then(r => {
const cs = r.elements[0];
return {
id: changesetID,
uid: cs.uid,
user: cs.user,
from: moment(cs.created_at, 'YYYY-MM-DDTHH:mm:ss\\Z')
.subtract(1, 'seconds')
.format('YYYY-MM-DDTHH:mm:ss\\Z'),
to: cs.closed_at || null,
comments: r.elements[0].discussion || [],
bbox: {
left: cs.minlon || -180,
bottom: cs.minlat || -90,
right: cs.maxlon || 180,
top: cs.maxlat || 90
}
};
});
}