diff --git a/assets/src/bundles/origin/visits-reporting.js b/assets/src/bundles/origin/visits-reporting.js index a24ab6c3..5bd6151e 100644 --- a/assets/src/bundles/origin/visits-reporting.js +++ b/assets/src/bundles/origin/visits-reporting.js @@ -1,144 +1,149 @@ /** - * Copyright (C) 2018-2021 The Software Heritage developers + * Copyright (C) 2018-2022 The Software Heritage developers * See the AUTHORS file at the top-level directory of this distribution * License: GNU Affero General Public License version 3, or any later version * See top-level LICENSE file for more information */ import {createVisitsHistogram} from './visits-histogram'; import {updateCalendar} from './visits-calendar'; import './visits-reporting.css'; // will hold all visits let allVisits; // will hold filtered visits to display let filteredVisits; // will hold currently displayed year let currentYear; // function to gather full visits function filterFullVisits(differentSnapshots) { const filteredVisits = []; for (let i = 0; i < allVisits.length; ++i) { if (allVisits[i].status !== 'full') continue; if (!differentSnapshots) { filteredVisits.push(allVisits[i]); } else if (filteredVisits.length === 0) { filteredVisits.push(allVisits[i]); } else { const lastVisit = filteredVisits[filteredVisits.length - 1]; if (allVisits[i].snapshot !== lastVisit.snapshot) { filteredVisits.push(allVisits[i]); } } } return filteredVisits; } // function to update the visits list view based on the selected year function updateVisitsList(year) { $('#swh-visits-list').children().remove(); const visitsByYear = []; for (let i = 0; i < filteredVisits.length; ++i) { if (filteredVisits[i].date.getUTCFullYear() === year) { visitsByYear.push(filteredVisits[i]); } } let visitsCpt = 0; const nbVisitsByRow = 4; let visitsListHtml = '