Django - How to track user progress across multiple days?
I have a django model that updates with the user's current time spent on the website:
totallearningtime = models.DecimalField(default = 0, decimal_places=2, max_digits=100) # total time user spent on website
And I have the following chart.js that I want to populate with the totallearningtime through the week, and reset at the begining of the next week:
(right now it has placeholder values)
Here is the code for the chart:
<script>
const ctx = document.getElementById("myChart");
// <block:setup:1>
const DATA_COUNT = 12;
const labels = [
"Mon",
"Tue",
"Wen",
"Thur",
"Fri",
"Sat",
"Sun",
];
const datapoints = [
0, 20, 20, 60, 60, 120, 140, 180, 120, 125, 105, 110, 170,
];
const data = {
labels: labels,
datasets: [
{
label: "Learning Time",
data: datapoints,
// borderColor: red,
fill: false,
cubicInterpolationMode: "monotone",
tension: 0.4,
},
],
};
new Chart(ctx, {
type: "line",
data: data,
options: {
responsive: true,
maintainAspectRatio: true,
plugins: {
title: {
display: false,
text: "Total Time: 5h 45m",
},
},
interaction: {
intersect: false,
},
scales: {
x: {
display: true,
title: {
display: true,
},
},
y: {
display: true,
title: {
display: true,
text: "Hours",
},
suggestedMin: 0,
suggestedMax: 200,
},
},
},
});
</script>
However, I cannot figure out how to do this. I want to make it so that I can track the user's totallearningtime throughout the week and reset it at the beginning of the next week
