mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-12 13:28:36 +03:00
Events now only have associations; when filters and narratives are needed fromevents, interpolate from evt.associations
This commit is contained in:
@@ -142,7 +142,7 @@ class Dashboard extends React.Component {
|
||||
let hasOne = false
|
||||
// add event if it has at least one matching filter
|
||||
for (let i = 0; i < activeFilters.length; i++) {
|
||||
if (ev.filters.includes(activeFilters[i].name)) {
|
||||
if (ev.associations.includes(activeFilters[i].name)) {
|
||||
hasOne = true
|
||||
break
|
||||
}
|
||||
|
||||
@@ -24,10 +24,8 @@ function createEventSchema (custom) {
|
||||
category: Joi.string().allow(''),
|
||||
category_full: Joi.string().allow(''),
|
||||
associations: Joi.array(),
|
||||
// narratives: Joi.array(),
|
||||
sources: Joi.array(),
|
||||
// filters: Joi.array().allow(''),
|
||||
tags: Joi.array().allow(''),
|
||||
// tags: Joi.array().allow(''),
|
||||
comments: Joi.string().allow(''),
|
||||
time_display: Joi.string().allow(''),
|
||||
// nested
|
||||
|
||||
@@ -84,11 +84,11 @@ export function validateDomain (domain, features) {
|
||||
function validateArray (items, domainKey, schema) {
|
||||
items.forEach(item => {
|
||||
// NB: backwards compatibility with 'tags' for 'filters'
|
||||
if (domainKey === 'events') {
|
||||
if (!item.filters && !!item.tags) {
|
||||
item.filters = item.tags
|
||||
}
|
||||
}
|
||||
// if (domainKey === 'events') {
|
||||
// if (!item.filters && !!item.tags) {
|
||||
// item.filters = item.tags
|
||||
// }
|
||||
// }
|
||||
validateArrayItem(item, domainKey, schema)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -49,9 +49,9 @@ export const selectEvents = createSelector(
|
||||
[getEvents, getActiveFilters, getActiveCategories, getTimeRange, getFeatures],
|
||||
(events, activeFilters, activeCategories, timeRange, features) => {
|
||||
return events.reduce((acc, event) => {
|
||||
const isMatchingFilter = (event.filters &&
|
||||
event.filters.map(filter =>
|
||||
activeFilters.includes(filter))
|
||||
const isMatchingFilter = (event.associations &&
|
||||
event.associations.map(association =>
|
||||
activeFilters.includes(association))
|
||||
.some(s => s)
|
||||
) || activeFilters.length === 0
|
||||
const isActiveFilter = isMatchingFilter || activeFilters.length === 0
|
||||
@@ -84,12 +84,16 @@ export const selectNarratives = createSelector(
|
||||
|
||||
/* populate narratives dict with events */
|
||||
events.forEach(evt => {
|
||||
evt.narratives.forEach(narrative => {
|
||||
// initialise
|
||||
if (!narratives[narrative]) { narratives[narrative] = narrativeSkeleton(narrative) }
|
||||
// add evt to steps
|
||||
// NB: insetSourceFrom is a 'curried' function to allow with maps
|
||||
narratives[narrative].steps.push(insetSourceFrom(sources)(evt))
|
||||
evt.associations.forEach(association => {
|
||||
const foundNarrative = narrativesMeta.find(narr => narr.id === association)
|
||||
if (!!foundNarrative) {
|
||||
const { id: narrId } = foundNarrative
|
||||
// initialise
|
||||
if (!narratives[narrId]) { narratives[narrId] = narrativeSkeleton(narrId) }
|
||||
// add evt to steps
|
||||
// NB: insetSourceFrom is a 'curried' function to allow with maps
|
||||
narratives[narrId].steps.push(insetSourceFrom(sources)(evt))
|
||||
}
|
||||
})
|
||||
})
|
||||
/* sort steps by time */
|
||||
@@ -100,14 +104,11 @@ export const selectNarratives = createSelector(
|
||||
|
||||
const existingAssociatedNarrative = narrativesMeta.find(n => n.id === key)
|
||||
|
||||
if (existingAssociatedNarrative) {
|
||||
if (!!existingAssociatedNarrative) {
|
||||
narratives[key] = {
|
||||
...existingAssociatedNarrative,
|
||||
...narratives[key]
|
||||
}
|
||||
} else {
|
||||
// Associations dont contain this narrative
|
||||
delete narratives[key]
|
||||
}
|
||||
})
|
||||
// Return narratives in original order
|
||||
|
||||
Reference in New Issue
Block a user