mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-08 03:18:36 +03:00
Refactored selectEvents to account for filter path strs; working coloring alg again; evts not showing up on timeline
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import moment from "moment";
|
||||
import hash from "object-hash";
|
||||
|
||||
import { ASSOCIATION_MODES } from "./constants";
|
||||
|
||||
let { DATE_FMT, TIME_FMT } = process.env;
|
||||
if (!DATE_FMT) DATE_FMT = "MM/DD/YYYY";
|
||||
if (!TIME_FMT) TIME_FMT = "HH:mm";
|
||||
@@ -204,6 +206,12 @@ export function getEventCategories(event, categories) {
|
||||
return matchedCategories;
|
||||
}
|
||||
|
||||
export function createFilterPathString(filter) {
|
||||
return filter.mode === ASSOCIATION_MODES.FILTER
|
||||
? filter.filter_paths.join("/")
|
||||
: "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Inset the full source represenation from 'allSources' into an event. The
|
||||
* function is 'curried' to allow easy use with maps. To use for a single
|
||||
@@ -394,7 +402,7 @@ export function calculateColorPercentages(set, coloringSet) {
|
||||
|
||||
innerSet.forEach((val) => {
|
||||
val.associations.forEach((a) => {
|
||||
const idx = associationMap[a];
|
||||
const idx = associationMap[createFilterPathString(a)];
|
||||
if (!idx && idx !== 0) return;
|
||||
associationCounts[idx] += 1;
|
||||
totalAssociations += 1;
|
||||
|
||||
@@ -137,6 +137,14 @@ export function validateDomain(domain, features) {
|
||||
// append events with datetime and sort
|
||||
sanitizedDomain.events = sanitizedDomain.events.filter((event, idx) => {
|
||||
event.id = idx;
|
||||
// event.associations comes in as a [association.ids...]; convert to actual association objects
|
||||
event.associations = event.associations.reduce((acc, id) => {
|
||||
const foundAssociation = sanitizedDomain.associations.find(
|
||||
(elem) => elem.id === id
|
||||
);
|
||||
if (foundAssociation) acc.push(foundAssociation);
|
||||
return acc;
|
||||
}, []);
|
||||
// if lat, long come in with commas, replace with decimal format
|
||||
event.latitude = event.latitude.replace(",", ".");
|
||||
event.longitude = event.longitude.replace(",", ".");
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
dateMax,
|
||||
isLatitude,
|
||||
isLongitude,
|
||||
createFilterPathString,
|
||||
} from "../common/utilities";
|
||||
import { isTimeRangedIn } from "./helpers";
|
||||
import { ASSOCIATION_MODES } from "../common/constants";
|
||||
@@ -76,14 +77,18 @@ export const selectEvents = createSelector(
|
||||
const isMatchingFilter =
|
||||
(event.associations &&
|
||||
event.associations
|
||||
.map((association) => activeFilters.includes(association))
|
||||
.filter((a) => a.mode === ASSOCIATION_MODES.FILTER)
|
||||
.map((association) =>
|
||||
activeFilters.includes(createFilterPathString(association))
|
||||
)
|
||||
.some((s) => s)) ||
|
||||
activeFilters.length === 0;
|
||||
const isActiveFilter = isMatchingFilter || activeFilters.length === 0;
|
||||
const isActiveCategory =
|
||||
(event.associations &&
|
||||
event.associations
|
||||
.map((association) => activeCategories.includes(association))
|
||||
.filter((a) => a.mode === ASSOCIATION_MODES.CATEGORY)
|
||||
.map((association) => activeCategories.includes(association.title))
|
||||
.some((s) => s)) ||
|
||||
activeCategories.length === 0;
|
||||
let isActiveTime = isTimeRangedIn(event, timeRange);
|
||||
|
||||
Reference in New Issue
Block a user