Skip to content

Commit

Permalink
fix dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
matyaskopp committed Sep 16, 2022
1 parent b75bde4 commit ccb5012
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/db/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ exports.getMonthlyCountsByService = (date, filter) => {
exports.getWeeklyCountsByService = (date, len, filter) => {
logger.trace();
logger.debug("TODO implement filter");
filter['overview'] = 1;
filter['tokens_incl'] = 1;
const {query, values, table} = createFilter(filter,2);
return new promise((resolve, reject) => {
const days_list = `
Expand Down Expand Up @@ -251,7 +253,7 @@ function createFilter(filter, add=1){
if('service_id' in filter) {
values.push(filter['service_id']);
query += ' AND service_id = $'+ (values.length+add) +' ';
} else {
} else if(!('overview' in filter)){
query += ' AND service_id IS NULL ';
}
return {
Expand Down
4 changes: 2 additions & 2 deletions app/routes/viewRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,14 @@ router.post('/add-token', function (req, res, next) {


async function getAdminDashboard(user, res){
const len = 21;
const len = 28;
const last_date = (new Date).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"]});
}

async function getUserDashboard(user, res){
const len = 21;
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"]});
Expand Down

0 comments on commit ccb5012

Please sign in to comment.