aggregationWLMContest = (data) => {
return dates.map((dateISO) => {
const date = new Date(dateISO);
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);
const photographed = data_noErrors.filter((d) => {
const tempDate = new Date(d.first_image_date);
const checkDate = tempDate <= date;
return d.first_image_date && checkDate;
});
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;
});
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;
});
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
};
});
}