Various changes after handling many error reports

This commit is contained in:
Pieter Vander Vennet 2024-08-09 20:38:13 +02:00
parent 9b7cdb3c17
commit bb82ea27d3
4 changed files with 31 additions and 24 deletions

View file

@ -163,7 +163,7 @@
},
"tags": [
"leisure=pitch",
"fixme=Toegevoegd met MapComplete, geometry nog uit te tekenen"
"fixme=Geometry to be drawn, added by MapComplete"
]
}
],

View file

@ -60,7 +60,6 @@ class HandleErrors extends Script {
console.log("Skipping GRB ")
continue
}
console.log(e.username, e.layout, e.message, parsed.date)
for (const pendingChange of e.pendingChanges) {
console.log(
"\t https://osm.org/" + pendingChange.type + "/" + pendingChange.id,
@ -75,6 +74,8 @@ class HandleErrors extends Script {
}
for (const parsed of all) {
console.log(parsed.message.username, parsed.message.layout, parsed.message.message, parsed.date)
const e = parsed.message
const neededIds = Changes.GetNeededIds(e.pendingChanges)
// We _do not_ pass in the Changes object itself - we want the data from OSM directly in order to apply the changes
@ -98,10 +99,7 @@ class HandleErrors extends Script {
newObjects: OsmObject[]
modifiedObjects: OsmObject[]
deletedObjects: OsmObject[]
} = new Changes({
dryRun: new ImmutableStore(true),
osmConnection,
}).CreateChangesetObjects(toUpload, objects)
} = changesObj.CreateChangesetObjects(toUpload, objects)
const changeset = Changes.createChangesetFor("", changes)
const path =
@ -110,31 +108,34 @@ class HandleErrors extends Script {
changeset ===
`<osmChange version='0.6' generator='Mapcomplete ${Constants.vNumber}'></osmChange>`
) {
console.log(
/*console.log(
"Changes for " + parsed.index + ": empty changeset, not creating a file for it"
)
)*/
} else if (createdChangesets.has(changeset)) {
console.log(
/* console.log(
"Changeset " +
parsed.index +
" is identical to previously seen changeset, not writing to file"
)
)*/
} else {
writeFileSync(path, changeset, "utf8")
const changesetWithMsg = `<!-- User: ${parsed.message.username} (${parsed.message.userid}) ${parsed.message.layout}; Version ${parsed.message.version}; Not uploaded due to ${parsed.message.message} -->
${changeset}`
writeFileSync(path, changesetWithMsg, "utf8")
createdChangesets.add(changeset)
console.log("Written", path, "with " + e.pendingChanges.length + " changes")
}
const refusedContent = JSON.stringify(refused)
if (refusedFiles.has(refusedContent)) {
console.log(
/* console.log(
"Refused changes for " +
parsed.index +
" is identical to previously seen changeset, not writing to file"
)
)*/
} else {
writeFileSync(path + ".refused.json", refusedContent, "utf8")
refusedFiles.add(refusedContent)
console.log("Written refused", path)
}
console.log("Written", path, "with " + e.pendingChanges.length + " changes")
}
}
}

View file

@ -440,15 +440,17 @@ export class Changes {
}
})
console.debug(
"Calculated the pending changes: ",
result.newObjects.length,
"new; ",
result.modifiedObjects.length,
"modified;",
result.deletedObjects,
"deleted"
)
if(!(result.newObjects.length === 0 && result.modifiedObjects.length === 0 && result.deletedObjects.length === 0)) {
console.debug(
"Calculated the pending changes: ",
result.newObjects.length,
"new; ",
result.modifiedObjects.length,
"modified;",
result.deletedObjects.length,
"deleted"
)
}
return result
}

View file

@ -154,6 +154,10 @@ export class ChangesetHandler {
if (this._reportError) {
this._reportError(e)
}
if((<XMLHttpRequest> e).status === 400){
// This request is invalid. We simply drop the changes and hope that someone will analyze what went wrong with it in the upload; we pretend everything went fine
return
}
console.warn(
"Could not open/upload changeset due to ",
e,
@ -195,7 +199,7 @@ export class ChangesetHandler {
"Could not reuse changeset " +
csId +
", might be closed: " +
(e.stacktrace ?? "" + e)
(e.stacktrace ?? e.status ?? "" + e)
)
}
console.warn("Could not upload, changeset is probably closed: ", e)