Skip to content

Commit

Permalink
Updates to match latest lint (patch)
Browse files Browse the repository at this point in the history
  • Loading branch information
zrrrzzt committed Jul 16, 2019
1 parent 6d52bbe commit 78568c5
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions lib/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports.total = async (request, response) => {
const db = await mongo()
const logs = db.collection(process.env.MONGODB_COLLECTION)
const { type, category } = request.params
const query = type ? { documentType: type, documentCategory: { '$in': category ? [category] : publicDocTypes } } : { documentCategory: { '$in': category ? [category] : publicDocTypes } }
const query = type ? { documentType: type, documentCategory: { $in: category ? [category] : publicDocTypes } } : { documentCategory: { $in: category ? [category] : publicDocTypes } }
logger('info', ['routes', 'total', 'type', type || 'any'])
try {
const count = await logs.countDocuments(query)
Expand Down Expand Up @@ -39,10 +39,10 @@ exports.schools = async (request, response) => {
const db = await mongo()
const logs = db.collection(process.env.MONGODB_COLLECTION)
const { type } = request.params
const query = type ? { documentType: type, documentCategory: { '$in': publicDocTypes } } : { documentCategory: { '$in': publicDocTypes } }
const query = type ? { documentType: type, documentCategory: { $in: publicDocTypes } } : { documentCategory: { $in: publicDocTypes } }
logger('info', ['routes', 'schools', 'type', type || 'any'])
logs.aggregate([{ '$match': query }, { '$group': { '_id': '$schoolName', 'total': { '$sum': 1 } } }])
.sort({ 'total': -1 }).toArray((error, data) => {
logs.aggregate([{ $match: query }, { $group: { _id: '$schoolName', total: { $sum: 1 } } }])
.sort({ total: -1 }).toArray((error, data) => {
if (error) {
logger('error', ['handle-stats', 'action', 'schools', error])
send(response, 500, error)
Expand All @@ -59,8 +59,8 @@ exports.categorySchools = async (request, response) => {
const { category } = request.params
const query = { documentCategory: category }
logger('info', ['routes', 'categorySchools', 'category', category])
logs.aggregate([{ '$match': query }, { '$group': { '_id': '$schoolName', 'total': { '$sum': 1 } } }])
.sort({ 'total': -1 }).toArray((error, data) => {
logs.aggregate([{ $match: query }, { $group: { _id: '$schoolName', total: { $sum: 1 } } }])
.sort({ total: -1 }).toArray((error, data) => {
if (error) {
logger('error', ['handle-stats', 'action', 'categorySchools', error])
send(response, 500, error)
Expand All @@ -75,10 +75,10 @@ exports.groups = async (request, response) => {
const db = await mongo()
const logs = db.collection(process.env.MONGODB_COLLECTION)
const { type } = request.params
const query = type ? { documentType: type, documentCategory: { '$in': publicDocTypes } } : { documentCategory: { '$in': publicDocTypes } }
const query = type ? { documentType: type, documentCategory: { $in: publicDocTypes } } : { documentCategory: { $in: publicDocTypes } }
logger('info', ['routes', 'groups', 'type', type || 'any'])
logs.aggregate([{ '$match': query }, { '$group': { '_id': '$studentMainGroupName', 'total': { '$sum': 1 } } }])
.sort({ 'total': -1 }).toArray((error, data) => {
logs.aggregate([{ $match: query }, { $group: { _id: '$studentMainGroupName', total: { $sum: 1 } } }])
.sort({ total: -1 }).toArray((error, data) => {
if (error) {
logger('error', ['handle-stats', 'action', 'groups', error])
send(response, 500, error)
Expand All @@ -95,8 +95,8 @@ exports.categoryClasses = async (request, response) => {
const { category } = request.params
const query = { documentCategory: category }
logger('info', ['routes', 'categoryClasses', 'category', category])
logs.aggregate([{ '$match': query }, { '$group': { '_id': '$studentMainGroupName', 'total': { '$sum': 1 } } }])
.sort({ 'total': -1 }).toArray((error, data) => {
logs.aggregate([{ $match: query }, { $group: { _id: '$studentMainGroupName', total: { $sum: 1 } } }])
.sort({ total: -1 }).toArray((error, data) => {
if (error) {
logger('error', ['handle-stats', 'action', 'categoryClasses', error])
send(response, 500, error)
Expand All @@ -111,9 +111,9 @@ exports.categories = async (request, response) => {
logger('info', ['handle-stats', 'action', 'categories'])
const db = await mongo()
const logs = db.collection(process.env.MONGODB_COLLECTION)
const query = { documentCategory: { '$in': publicDocTypes } }
logs.aggregate([{ '$match': query }, { '$group': { '_id': '$documentCategory', 'total': { '$sum': 1 } } }])
.sort({ 'total': -1 }).toArray((error, data) => {
const query = { documentCategory: { $in: publicDocTypes } }
logs.aggregate([{ $match: query }, { $group: { _id: '$documentCategory', total: { $sum: 1 } } }])
.sort({ total: -1 }).toArray((error, data) => {
if (error) {
logger('error', ['handle-stats', 'action', 'categories', error])
send(response, 500, error)
Expand All @@ -129,8 +129,8 @@ exports.time = async (request, response) => {
const db = await mongo()
const logs = db.collection(process.env.MONGODB_COLLECTION)
const { type, category } = request.params
const query = type ? { documentType: type, documentCategory: { '$in': category ? [category] : publicDocTypes } } : { documentCategory: { '$in': category ? [category] : publicDocTypes } }
logs.find(query, { 'skjemaUtfyllingStart': 1, 'skjemaUtfyllingStop': 1 }).toArray((error, data) => {
const query = type ? { documentType: type, documentCategory: { $in: category ? [category] : publicDocTypes } } : { documentCategory: { $in: category ? [category] : publicDocTypes } }
logs.find(query, { skjemaUtfyllingStart: 1, skjemaUtfyllingStop: 1 }).toArray((error, data) => {
if (error) {
logger('error', ['handle-stats', 'action', 'time', error])
send(response, 500, error)
Expand Down Expand Up @@ -158,7 +158,7 @@ exports.usage = async (request, response) => {
const db = await mongo()
const logs = db.collection(process.env.MONGODB_COLLECTION)
const { type } = request.params
const query = type ? { documentType: type, documentCategory: { '$in': publicDocTypes } } : { documentCategory: { '$in': publicDocTypes } }
const query = type ? { documentType: type, documentCategory: { $in: publicDocTypes } } : { documentCategory: { $in: publicDocTypes } }
logger('info', ['routes', 'usage', 'type', type || 'any'])
logs.distinct('userName', query, (error, data) => {
if (error) {
Expand Down Expand Up @@ -190,9 +190,9 @@ exports.email = async (request, response) => {
const logs = db.collection(process.env.MONGODB_COLLECTION)
logger('info', ['handle-stats', 'action', 'email'])
const query = {
'documentType': 'yff',
'documentCategory': 'yff-bekreftelse-bedrift',
'kopiPrEpost': { '$exists': true, '$ne': '' }
documentType: 'yff',
documentCategory: 'yff-bekreftelse-bedrift',
kopiPrEpost: { $exists: true, $ne: '' }
}
try {
const count = await logs.countDocuments(query)
Expand Down

0 comments on commit 78568c5

Please sign in to comment.