forked from MapComplete/MapComplete
chore: automated housekeeping...
This commit is contained in:
parent
a178de3e03
commit
bb6b053429
131 changed files with 7447 additions and 5143 deletions
|
|
@ -3,49 +3,63 @@ import ThemeConfig from "../../Models/ThemeConfig/ThemeConfig"
|
|||
import { OsmObject } from "../../Logic/Osm/OsmObject"
|
||||
|
||||
export class HistoryUtils {
|
||||
|
||||
public static readonly personalTheme = new ThemeConfig(<any> all_layers, true)
|
||||
public static readonly personalTheme = new ThemeConfig(<any>all_layers, true)
|
||||
private static ignoredLayers = new Set<string>(["fixme"])
|
||||
public static determineLayer(properties: Record<string, string>){
|
||||
public static determineLayer(properties: Record<string, string>) {
|
||||
return this.personalTheme.getMatchingLayer(properties, this.ignoredLayers)
|
||||
}
|
||||
|
||||
public static tagHistoryDiff(step: OsmObject, history: OsmObject[]): {
|
||||
key: string,
|
||||
value?: string,
|
||||
oldValue?: string,
|
||||
public static tagHistoryDiff(
|
||||
step: OsmObject,
|
||||
history: OsmObject[]
|
||||
): {
|
||||
key: string
|
||||
value?: string
|
||||
oldValue?: string
|
||||
step: OsmObject
|
||||
}[] {
|
||||
const previous = history[step.version - 2]
|
||||
if (!previous) {
|
||||
return Object.keys(step.tags).filter(key => !key.startsWith("_") && key !== "id").map(key => ({
|
||||
key, value: step.tags[key], step
|
||||
}))
|
||||
return Object.keys(step.tags)
|
||||
.filter((key) => !key.startsWith("_") && key !== "id")
|
||||
.map((key) => ({
|
||||
key,
|
||||
value: step.tags[key],
|
||||
step,
|
||||
}))
|
||||
}
|
||||
const previousTags = previous.tags
|
||||
return Object.keys(step.tags).filter(key => !key.startsWith("_") )
|
||||
.map(key => {
|
||||
return Object.keys(step.tags)
|
||||
.filter((key) => !key.startsWith("_"))
|
||||
.map((key) => {
|
||||
const value = step.tags[key]
|
||||
const oldValue = previousTags[key]
|
||||
return {
|
||||
key, value, oldValue, step
|
||||
key,
|
||||
value,
|
||||
oldValue,
|
||||
step,
|
||||
}
|
||||
}).filter(ch => ch.oldValue !== ch.value)
|
||||
})
|
||||
.filter((ch) => ch.oldValue !== ch.value)
|
||||
}
|
||||
|
||||
public static fullHistoryDiff(histories: OsmObject[][], onlyShowUsername?: Set<string>){
|
||||
const allDiffs: {key: string, oldValue?: string, value?: string}[] = [].concat(...histories.map(
|
||||
history => {
|
||||
const filtered = history.filter(step => !onlyShowUsername || onlyShowUsername?.has(step.tags["_last_edit:contributor"] ))
|
||||
public static fullHistoryDiff(histories: OsmObject[][], onlyShowUsername?: Set<string>) {
|
||||
const allDiffs: { key: string; oldValue?: string; value?: string }[] = [].concat(
|
||||
...histories.map((history) => {
|
||||
const filtered = history.filter(
|
||||
(step) =>
|
||||
!onlyShowUsername ||
|
||||
onlyShowUsername?.has(step.tags["_last_edit:contributor"])
|
||||
)
|
||||
const diffs: {
|
||||
key: string;
|
||||
value?: string;
|
||||
key: string
|
||||
value?: string
|
||||
oldValue?: string
|
||||
}[][] = filtered.map(step => HistoryUtils.tagHistoryDiff(step, history))
|
||||
}[][] = filtered.map((step) => HistoryUtils.tagHistoryDiff(step, history))
|
||||
return [].concat(...diffs)
|
||||
}
|
||||
))
|
||||
})
|
||||
)
|
||||
return allDiffs
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue