Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
Improve missing data list
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminaaron committed May 3, 2024
1 parent 9acd88c commit 7e79f55
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.1",
"description": "FörderFunke as a web app, the data only lives within the browser session locally",
"dependencies": {
"@foerderfunke/matching-engine": "^0.3.8",
"@foerderfunke/matching-engine": "^0.3.9",
"choices.js": "^10.2.0"
},
"scripts": {
Expand Down
33 changes: 25 additions & 8 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h3>Report</h3>
placeholderValue: "No focus set --> prioritization of missing data points goes over all requirement profiles",
});

let missingData
let validateAllReport

let userProfile = `
@prefix ff: <https://foerderfunke.org/default#> .
Expand Down Expand Up @@ -89,7 +89,7 @@ <h3>Report</h3>

let turtleMap = await loadFiles()

let validateAllReport = await MatchingEngine.validateAll(userProfile, turtleMap.shacl, turtleMap.datafields, turtleMap.materialization)
validateAllReport = await MatchingEngine.validateAll(userProfile, turtleMap.shacl, turtleMap.datafields, turtleMap.materialization)
console.log("validateAllReport", validateAllReport)

buildFocusInputSelectChoices(validateAllReport.metadata);
Expand All @@ -105,24 +105,41 @@ <h3>Report</h3>
document.getElementById("reportTable").appendChild(tr)
}

missingData = validateAllReport.missingUserInputsAggregated
buildPrioritizedMissingDataList()
}

function buildPrioritizedMissingDataList() {
let div = document.getElementById("missingDataPointsDiv")
div.textContent = ""
let prioritizedList = []

let missingData = validateAllReport.missingUserInputsAggregated
let metadata = validateAllReport.metadata

for (let key of Object.keys(missingData)) {
prioritizedList.push([missingData[key].predicate.split("#")[1], missingData[key].usedIn.length])
let datafield = missingData[key]
let usedInTitles = []
let lastMissingCounter = 0
for (let usedInRP of datafield.usedIn) {
usedInTitles.push(metadata[usedInRP.id].title + (usedInRP.isLastMissingUserInput ? " (!)" : ""))
if (usedInRP.isLastMissingUserInput) lastMissingCounter += 1
}
prioritizedList.push({
label: datafield.label ?? datafield.predicate.split("#")[1],
score: datafield.usedIn.length + lastMissingCounter,
usedInTitles: usedInTitles
})
}
prioritizedList.sort((a, b) => b[1] - a[1])
prioritizedList.sort((a, b) => b.score - a.score)
prioritizedList.forEach((entry) => {
let textNode = document.createTextNode(entry[1] + ": ")
div.appendChild(textNode)
let spanEl = document.createElement("span")
spanEl.title = entry.usedInTitles.join("\n")
let textNode = document.createTextNode(entry.score + ": ")
spanEl.appendChild(textNode)
div.appendChild(spanEl)
let a = document.createElement("a")
a.href = "#"
a.textContent = entry[0]
a.textContent = entry.label
a.addEventListener("click", function(event) {
event.preventDefault()
let input = prompt("What is your value for " + entry[0])
Expand Down

0 comments on commit 7e79f55

Please sign in to comment.