mirror of
https://github.com/huhu/rust-search-extension
synced 2024-11-15 08:07:08 +00:00
Only count the last week history statistics
This commit is contained in:
parent
b499410ab3
commit
de454df56c
2 changed files with 8 additions and 2 deletions
|
@ -61,7 +61,7 @@
|
|||
</div>
|
||||
<div class="statistics-page">
|
||||
<a href="../stats/index.html" target="_blank" class="stats-link">
|
||||
<b id="stats-week-count">0</b> searchings this week >
|
||||
<b id="stats-week-count">0</b> searchings last week >
|
||||
</a>
|
||||
</div>
|
||||
<div style="margin-top: 30px; font-size: 11px;text-align: center">
|
||||
|
|
|
@ -77,10 +77,16 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||
crateRegistry.onchange = function() {
|
||||
settings.crateRegistry = crateRegistry.value;
|
||||
};
|
||||
|
||||
|
||||
let history = JSON.parse(localStorage.getItem("history"));
|
||||
let statsPage = document.querySelector(".statistics-page");
|
||||
let statsWeekCount = statsPage.querySelector("#stats-week-count");
|
||||
let now = new Date();
|
||||
let weekAgo = now.setDate(now.getDate() - 7);
|
||||
history = history.filter(({time}) => {
|
||||
return weekAgo <= time;
|
||||
});
|
||||
|
||||
if(history) {
|
||||
statsWeekCount.textContent = `${history.length}`
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue