Filter out duplicate speakers

This commit is contained in:
tree 2023-03-15 15:19:10 +01:00
parent 8ab6e34401
commit 8f8aa41337
3 changed files with 20 additions and 4 deletions

View File

@ -35,3 +35,17 @@ export function getFlagEmoji(str, mapper = true) {
.map((char) => 127397 + char.charCodeAt());
return String.fromCodePoint(...codePoints);
}
export function processItemsList (arr) {
const out = []
const ids = []
for (const sp of arr) {
// filter out duplicates
if (ids.includes(sp.id)) {
continue
}
out.push(sp)
ids.push(sp.id)
}
return out
}

View File

@ -4,6 +4,7 @@
import Disclaimer from '$lib/components/Disclaimer.svelte';
import Footer from '$lib/components/Footer.svelte';
import { page } from '$app/stores';
import { processItemsList } from '$lib/utils.js';
export let data;
$: entry = $page.params.entry;
@ -73,7 +74,7 @@
class="grid grid-cols-3 sm:grid-cols-3 md:grid-cols-6 xl:grid-cols-8 my-6 text-center text-xl"
>
<CollectionList
arr={data.bundle.speakers.filter((s) => !['cz', 'sk'].includes(s.country)).sort((x, y) => (x.name > y.name ? 1 : -1))}
arr={processItemsList(data.bundle.speakers.filter((s) => !['cz', 'sk'].includes(s.country)).sort((x, y) => (x.name > y.name ? 1 : -1)))}
{entry}
offer="true"
/>
@ -85,7 +86,7 @@
class="grid grid-cols-3 sm:grid-cols-3 md:grid-cols-6 xl:grid-cols-8 my-6 text-center text-xl"
>
<CollectionList
arr={data.bundle.speakers.filter((s) => ['cz', 'sk'].includes(s.country)).sort((x, y) => (x.name > y.name ? 1 : -1))}
arr={processItemsList(data.bundle.speakers.filter((s) => ['cz', 'sk'].includes(s.country)).sort((x, y) => (x.name > y.name ? 1 : -1)))}
{entry}
offer="true"
/>

View File

@ -8,7 +8,7 @@
import Footer from '$lib/components/Footer.svelte';
import Header from '$lib/components/Header.svelte';
import EventTypeBadge from '$lib/components/EventTypeBadge.svelte';
import { formatItemDate, bareDomain, getFlagEmoji } from '$lib/utils.js';
import { formatItemDate, bareDomain, getFlagEmoji, processItemsList } from '$lib/utils.js';
import makeBlockie from 'ethereum-blockies-base64';
import TimelineHeatmap from '$lib/components/TimelineHeatmap.svelte';
import ItemLogo from '$lib/components/ItemLogo.svelte';
@ -23,7 +23,8 @@
let entry = $page.params.entry;
$: type = $page.params.type;
$: tc = config.collections[type];
$: items = data.bundle[type];
$: items = type === 'speakers' ? processItemsList(data.bundle[type]) : data.bundle[type]
function processItems(_items, query = {}) {
if (!_items) return [];