Skip to content

Commit

Permalink
use map instead of reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
ambrazasp committed Aug 6, 2024
1 parent e3f3183 commit f8e18ff
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions services/events.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,9 @@ export default class EventsService extends moleculer.Service {
const eventsQuery = adapter.computeQuery(table, query);
const tagsById: { [key: string]: Tag } = await ctx.call('tags.find', { mapping: 'id' });

const appTypeCaseWhenClause = Object.keys(APP_TYPE).reduce((acc: string[], key: string) => {
if (key && APP_TYPE[key]) {
acc.push(`WHEN apps.key = '${key}' THEN '${APP_TYPE[key]}'`);
}
return acc;
}, []);
const appTypeCaseWhenClause = Object.keys(APP_TYPE).map(
(key: string) => `WHEN apps.key = '${key}' THEN '${APP_TYPE[key]}'`,
);

const appTypeCaseClause = `CASE ${appTypeCaseWhenClause.join(' ')} END AS app_type`;

Expand Down

0 comments on commit f8e18ff

Please sign in to comment.