Public
Edited
Oct 14, 2022
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
aggregationWLMContest = (data) => {
return dates.map((dateISO) => {
const date = new Date(dateISO);
// spot database errors
const errors = data.filter((d) => {
const type1 = d.first_image_date && !d.wlm_n;
const type2 = !d.first_revision;
d.error = { type1, type2 };
return type1 || type2;
});
const data_noErrors = data.filter((d) => errors.indexOf(d) < 0);
// get photographed monuments
const photographed = data_noErrors.filter((d) => {
const tempDate = new Date(d.first_image_date);
const checkDate = tempDate <= date;
return d.first_image_date && checkDate; // immagine WLM!!!
});
// get inContest monuments
const data_noPhotographed = data_noErrors.filter(
(d) => photographed.indexOf(d) < 0
);
const inContest = data_noPhotographed.filter((d) => {
const tempDate = new Date(d.start);
const checkDate = tempDate <= date;
return d.start && checkDate; // la data di autorizzazione
});
// get onWIki monuments
const data_noInContest = data_noPhotographed.filter(
(d) => inContest.indexOf(d) < 0
);
const onWIkidata = data_noInContest.filter((d) => {
const tempDate = new Date(d.first_revision);
const checkDate = tempDate <= date;
return d.first_revision && checkDate; // prima revisione pagina wikidata
});
// get notYetOnWIkidata
const notYetOnWIkidata = data_noInContest.filter(
(d) => onWIkidata.indexOf(d) < 0
);
return {
date: dateISO,
groups_exclusive: { photographed, inContest, onWIkidata },
groups: {
photographed,
inContest: [photographed, inContest].flat(),
onWIkidata: [photographed, inContest, onWIkidata].flat()
},
groups_sum: photographed.length + inContest.length + onWIkidata.length,
notYetOnWIkidata: notYetOnWIkidata.length,
check_sum:
photographed.length +
inContest.length +
onWIkidata.length +
notYetOnWIkidata.length +
errors.length,
errors
};
});
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
aggregationAllPhotosCoverage = (data) => {
return dates.map((dateISO) => {
const date = new Date(dateISO);
// spot database errors
const errors = data.filter((d) => {
const type1 = d.first_image_date && !d.wlm_n;
const type2 = !d.first_revision;
d.error = { type1, type2 };
return type1 || type2;
});
// get monuments with pictures (photos that can be also unrelated to WLM)
const data_noErrors = data.filter((d) => errors.indexOf(d) < 0);
const withPicture = data_noErrors.filter((d) => {
const check1 = d.first_image_date || d.first_image_date_commons;
const first_wlm_image_date = new Date(d.first_image_date);
const relevant_image_date = new Date(d.first_image_date_commons);
const checkDate =
Math.min(first_wlm_image_date, relevant_image_date) <= date;
return check1 && checkDate;
});
// get all other monuments (which should have no pictures at all)
const data_noWithPicture = data_noErrors.filter(
(d) => withPicture.indexOf(d) < 0
);
const onWIkidataOnly = data_noWithPicture.filter((d) => {
const tempDate = new Date(d.first_revision);
const checkDate = tempDate <= date;
return d.first_revision && checkDate; // prima revisione pagina wikidata
});
// get notYetOnWIkidata
const notYetOnWIkidata = data_noWithPicture.filter(
(d) => onWIkidataOnly.indexOf(d) < 0
);

return {
date: dateISO,
groups_exclusive: { withPicture, onWIkidataOnly },
groups: {
withPicture,
onWIkidataOnly: [withPicture, onWIkidataOnly].flat()
},
groups_sum: withPicture.length + onWIkidataOnly.length,
notYetOnWIkidata: notYetOnWIkidata.length,
check_sum:
withPicture.length +
onWIkidataOnly.length +
notYetOnWIkidata.length +
errors.length,
errors
};
});
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more