Skip to content

Commit

Permalink
use (current date - 1 day) as the last date in card view
Browse files Browse the repository at this point in the history
  • Loading branch information
matyaskopp committed Sep 17, 2022
1 parent 0bfb97f commit 2b32cef
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/routes/viewRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,18 @@ router.post('/add-token', function (req, res, next) {

async function getAdminDashboard(user, res){
const len = 28;
const last_date = (new Date).toISOString().slice(0,10);
let d = new Date();
d.setDate(d.getDate() - 1);
const last_date = d.toISOString().slice(0,10);
const weekly = await adminController.getWeeklyCountsByService(last_date, len);
res.render('dashboard', {user: user, servicecounts: weekly, period_length: len, date: Date.parse(last_date), initialview: (new Date).toISOString().slice(0,7), admin_dashboard_active: true,type: 'user', filter: 'all', datalines: ["units", "requests", "body_bytes_sent"]});
res.render('dashboard', {user: user, servicecounts: weekly, period_length: len, date: Date.parse(last_date), initialview: d.toISOString().slice(0,7), admin_dashboard_active: true,type: 'user', filter: 'all', datalines: ["units", "requests", "body_bytes_sent"]});
}

async function getUserDashboard(user, res){
const len = 28;
const last_date = (new Date).toISOString().slice(0,10);
const weekly = await userController.getWeeklyCountsByService(user.user_id, last_date , len);
res.render('dashboard', {user: user, servicecounts: weekly, period_length: len, date: Date.parse(last_date), initialview: (new Date).toISOString().slice(0,7), user_dashboard_active: true, type: 'user', filter: user.user_id, datalines: ["units", "requests", "body_bytes_sent"]});
res.render('dashboard', {user: user, servicecounts: weekly, period_length: len, date: Date.parse(last_date), initialview: d.toISOString().slice(0,7), user_dashboard_active: true, type: 'user', filter: user.user_id, datalines: ["units", "requests", "body_bytes_sent"]});
}

module.exports = router;

0 comments on commit 2b32cef

Please sign in to comment.