Skip to content

Commit

Permalink
Merge pull request #713 from swgsgo/pre-staging
Browse files Browse the repository at this point in the history
Changed notifications criteria to last 3 weeks
  • Loading branch information
swgsgo authored Sep 27, 2024
2 parents 325a1de + d61b2ed commit 6f31ce4
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion _includes/notifications.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,23 @@
let year = new Date().getFullYear();
let pastmonth = (new Date().getMonth()).toString().padStart(2, '0');
let currentmonth = (new Date().getMonth() + 1).toString().padStart(2, '0');

// Build dates array from last 3 weeks
let datesArray = [];
for (let i = 0; i < 21; i++) {
let date = new Date(new Date().setDate(new Date().getDate() - i)).toISOString().split('T')[0];
datesArray.push(date);
}

// let filteredData = data.filter(function(item) {
// return item.Date.includes(year + '-' + currentmonth);
// });

// Filter data by dates array
let filteredData = data.filter(function(item) {
return item.Date.includes(year + '-' + currentmonth);
return datesArray.includes(item.Date.split('T')[0]);
});

if (filteredData.length === 0) {
output = 'No new notifications';
} else {
Expand Down

0 comments on commit 6f31ce4

Please sign in to comment.