Skip to content

Commit

Permalink
Fix #3304 and #1350
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanschroeder committed Feb 16, 2021
1 parent 3071b08 commit 0586dca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
15 changes: 9 additions & 6 deletions pages/instructorIssues/instructorIssues.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const sqlLoader = require('@prairielearn/prairielib/sql-loader');

const sql = sqlLoader.loadSqlEquiv(__filename);

const PAGE_SIZE = 100;
const PAGE_SIZE = 10;

const commonQueries = {
allOpenQuery: 'is:open',
Expand Down Expand Up @@ -108,21 +108,24 @@ router.get('/', function(req, res, next) {
if (result.rowCount != 2) return next(new Error('unable to obtain issue count, rowCount = ' + result.rowCount));
res.locals.closedCount = result.rows[0].count;
res.locals.openCount = result.rows[1].count;
res.locals.issueCount = res.locals.closedCount + res.locals.openCount;

_.assign(res.locals, paginate.pages(req.query.page, res.locals.issueCount, PAGE_SIZE));
res.locals.shouldPaginate = res.locals.issueCount > PAGE_SIZE;

var params = {
course_id: res.locals.course.id,
offset: (res.locals.currPage - 1) * PAGE_SIZE,
offset: 0,
limit: PAGE_SIZE,
};
if (_.isInteger(Number(req.query.page)))
params.offset = (Number(req.query.page) - 1) * PAGE_SIZE;
_.assign(params, filters);

sqldb.query(sql.select_issues, params, function(err, result) {
if (ERR(err, next)) return;

res.locals.issueCount = result.rowCount ? result.rows[0].issue_count : 0;

_.assign(res.locals, paginate.pages(req.query.page, res.locals.issueCount, PAGE_SIZE));
res.locals.shouldPaginate = res.locals.issueCount > PAGE_SIZE;

// Add human-readable relative dates to each row
result.rows.forEach((row) => {
row.relative_date = moment(row.formatted_date).from(row.now_date);
Expand Down
3 changes: 2 additions & 1 deletion pages/instructorIssues/instructorIssues.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ SELECT
i.student_message,
i.variant_id,
i.open,
i.manually_reported
i.manually_reported,
COUNT(*) OVER() AS issue_count
FROM
issues_select_with_filter (
$filter_is_open,
Expand Down

0 comments on commit 0586dca

Please sign in to comment.