chore: automated housekeeping...

This commit is contained in:
Pieter Vander Vennet 2025-04-26 22:06:59 +02:00
parent 6122d2a42c
commit a2bcfead15
22 changed files with 448 additions and 86 deletions

View file

@ -32,7 +32,9 @@
}[]
> = allHistories.mapD((histories) => HistoryUtils.fullHistoryDiff(histories, usernames))
const trs = shared_questions.tagRenderings.map((tr) => new TagRenderingConfig(<TagRenderingConfigJson>tr))
const trs = shared_questions.tagRenderings.map(
(tr) => new TagRenderingConfig(<TagRenderingConfigJson>tr)
)
function detectQuestion(key: string): TagRenderingConfig {
return trs.find((tr) => tr.freeform?.key === key)
@ -69,7 +71,7 @@
keyCounts.forEach((values: Map<string, OsmObject[]>, key: string) => {
const keyTotal: { value: string; features: Feature[] }[] = []
values.forEach((count, value) => {
keyTotal.push({ value, features: count.map(step => step.asGeoJson()) })
keyTotal.push({ value, features: count.map((step) => step.asGeoJson()) })
})
let countForKey: Feature[] = []
for (const { features } of keyTotal) {
@ -78,10 +80,14 @@
keyTotal.sort((a, b) => b.features.length - a.features.length)
const tr = detectQuestion(key)
perKey.push({
count: countForKey.length, tr, key, values: keyTotal.map(({ value, features }) => ({
count: countForKey.length,
tr,
key,
values: keyTotal.map(({ value, features }) => ({
value,
count: features.length
})), features: countForKey
count: features.length,
})),
features: countForKey,
})
})
perKey.sort((a, b) => b.count - a.count)
@ -118,14 +124,13 @@
{/each}
</ul>
{#if diff.tr}
<div class="w-48 h-48">
<div class="h-48 w-48">
<ToSvelte
construct={new TagRenderingChart(diff.features, diff.tr, {
groupToOtherCutoff: 0,
chartType: "pie",
sort: true,
})}
groupToOtherCutoff: 0,
chartType: "pie",
sort: true,
})}
/>
</div>
{:else}

View file

@ -44,37 +44,37 @@ export class HistoryUtils {
.filter((ch) => ch.oldValue !== ch.value)
}
public static fullHistoryDiff(histories: OsmObject[][], onlyShowUsername?: Set<string>): {
key: string;
value?: string;
oldValue?: string;
public static fullHistoryDiff(
histories: OsmObject[][],
onlyShowUsername?: Set<string>
): {
key: string
value?: string
oldValue?: string
step: OsmObject
}[] {
const allDiffs: {
key: string;
value?: string;
oldValue?: string;
key: string
value?: string
oldValue?: string
step: OsmObject
}[] = []
for (const history of histories) {
const filtered = history.filter(
(step) =>
!onlyShowUsername ||
onlyShowUsername?.has(step.tags["_last_edit:contributor"])
!onlyShowUsername || onlyShowUsername?.has(step.tags["_last_edit:contributor"])
)
for (const step of filtered) {
const diff: {
key: string;
value?: string;
oldValue?: string;
key: string
value?: string
oldValue?: string
step: OsmObject
}[] = HistoryUtils.tagHistoryDiff(step, history)
allDiffs.push(...diff)
}
}
return allDiffs
}
}

View file

@ -71,7 +71,6 @@
}
})
let state = {
mapProperties: maplibremap,
searchState: {
@ -175,10 +174,9 @@
}
map.data.flyTo({
zoom: 14,
center: [suggestion.lon, suggestion.lat]
center: [suggestion.lon, suggestion.lat],
})
}
</script>
<div class="flex h-screen w-full flex-col">

View file

@ -55,9 +55,12 @@
{#if $allowFilters}
<FilterResults {state} />
{/if}
<GeocodeResults {state} on:select={(select) => {
state.searchState.applyGeocodeResult(select.detail)
}}>
<GeocodeResults
{state}
on:select={(select) => {
state.searchState.applyGeocodeResult(select.detail)
}}
>
<svelte:fragment slot="if-no-results">
{#if $recentlySeen?.length > 0}
<SidebarUnit>

View file

@ -1,7 +1,11 @@
import { FixedUiElement } from "./Base/FixedUiElement"
import BaseUIElement from "./BaseUIElement"
import { default as FeatureTitle } from "./Popup/Title.svelte"
import { RenderingSpecification, SpecialVisualization, SpecialVisualizationState } from "./SpecialVisualization"
import {
RenderingSpecification,
SpecialVisualization,
SpecialVisualizationState,
} from "./SpecialVisualization"
import { HistogramViz } from "./Popup/HistogramViz"
import { UploadToOsmViz } from "./Popup/UploadToOsmViz"
import { MultiApplyViz } from "./Popup/MultiApplyViz"
@ -36,11 +40,8 @@ import { UISpecialVisualisations } from "./SpecialVisualisations/UISpecialVisual
import { SettingsVisualisations } from "./SpecialVisualisations/SettingsVisualisations"
import { ReviewSpecialVisualisations } from "./SpecialVisualisations/ReviewSpecialVisualisations"
import { DataImportSpecialVisualisations } from "./SpecialVisualisations/DataImportSpecialVisualisations"
import TagrenderingManipulationSpecialVisualisations
from "./SpecialVisualisations/TagrenderingManipulationSpecialVisualisations"
import {
WebAndCommunicationSpecialVisualisations
} from "./SpecialVisualisations/WebAndCommunicationSpecialVisualisations"
import TagrenderingManipulationSpecialVisualisations from "./SpecialVisualisations/TagrenderingManipulationSpecialVisualisations"
import { WebAndCommunicationSpecialVisualisations } from "./SpecialVisualisations/WebAndCommunicationSpecialVisualisations"
import ClearGPSHistory from "./BigComponents/ClearGPSHistory.svelte"
import AllFeaturesStatistics from "./Statistics/AllFeaturesStatistics.svelte"