Skip to content

Commit

Permalink
Fixing defaults.. Again.
Browse files Browse the repository at this point in the history
  • Loading branch information
rootelement committed Sep 23, 2020
1 parent 0eb9ab6 commit a915589
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/services/TermsOfUseService.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,16 +409,16 @@ deleteTermsOfUse.schema = {
* @returns {Object} the search result, contain total/page/perPage and result array
*/
async function searchTermsOfUses (criteria) {
const page = criteria.page || 1
const perPage = criteria.perPage || 20
const page = criteria.page > 0 ? criteria.page : 1
const perPage = criteria.perPage > 0 ? criteria.perPage : 20

const countResult = await TermsOfUse.findOne({
attributes: [[models.Sequelize.fn('COUNT', models.Sequelize.col('id')), 'total']],
where: _.assign({ deletedAt: null }, _.omit(criteria, ['perPage', 'page'])),
raw: true
})

const result = await TermsOfUse.findAll({
const query = {
order: [['id', 'ASC']],
attributes: ['id', 'legacyId', 'title', 'url', 'agreeabilityTypeId'],
include: [
Expand All @@ -435,7 +435,10 @@ async function searchTermsOfUses (criteria) {
limit: perPage,
offset: (page - 1) * perPage,
raw: true
})
}
const result = await TermsOfUse.findAll(query)

logger.debug(`Query: ${JSON.stringify(query)}`)

for (const element of result) {
convertRawData(element, false)
Expand Down

0 comments on commit a915589

Please sign in to comment.