Skip to content
Snippets Groups Projects
Commit 30c477c4 authored by Paolo.Brasolin's avatar Paolo.Brasolin
Browse files

feat: #be chart word performance

parent 9c641e7f
No related branches found
No related tags found
No related merge requests found
Pipeline #23947 passed with warnings
......@@ -156,3 +156,61 @@ new Chart(
document.getElementById("devicesBehaviourChart"),
devicesBehaviourConfig,
);
//=[ Words performance ]========================================================
const wordsPerformanceData = JSON.parse(
document.getElementById("wordsPerformanceData").textContent,
);
const wordsPerformanceConfig = {
type: "scatter",
data: {
datasets: [
{
data: wordsPerformanceData,
backgroundColor: "blue",
},
],
},
pointDot: true,
options: {
maintainAspectRatio: true,
aspectRatio: 1,
scales: {
x: {
title: {
display: true,
text: "OCR confidence",
},
},
y: {
title: {
display: true,
text: "Avg shot similarity",
},
},
},
plugins: {
legend: { display: false },
tooltip: {
callbacks: {
label: (context) => {
return `[${context.raw.ocr_transcript}](${context.parsed.x.toFixed(
2,
)};${context.parsed.y.toFixed(2)})`;
},
},
},
},
parsing: {
xAxisKey: "ocr_confidence",
yAxisKey: "avg_similarity",
},
},
};
new Chart(
document.getElementById("wordsPerformanceChart"),
wordsPerformanceConfig,
);
......@@ -83,6 +83,18 @@ server.get("/", async (request, reply) => {
.from(normalizedGames.as("g"))
.groupBy("device_id");
const wordsPerformance = await connection
.select(
connection.raw(
"words.id, words.ocr_transcript, words.ocr_confidence, AVG(shots.similarity) as avg_similarity",
),
)
.from("shots")
.join("clues", "clues.id", "shots.clue_id")
.join("words", "words.id", "clues.word_id")
.whereNotNull("shots.similarity")
.groupBy("words.id");
const devicesByDate = await connection
.table("games")
.select(connection.raw("COUNT(DISTINCT device_id), DATE(began_at)"))
......@@ -116,6 +128,7 @@ server.get("/", async (request, reply) => {
gamesByDate,
shotsByDuration,
devicesBehaviour,
wordsPerformance,
});
});
......
......@@ -93,6 +93,11 @@
<script id="devicesBehaviourData"
type="application/json"><%- JSON.stringify(devicesBehaviour) %></script>
<canvas id="devicesBehaviourChart"></canvas>
<h1>Words performance</h1>
<script id="wordsPerformanceData"
type="application/json"><%- JSON.stringify(wordsPerformance) %></script>
<canvas id="wordsPerformanceChart"></canvas>
</main>
</div>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment