Skip to content

Commit

Permalink
Install lodash.keys and fix Lodash mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
danyalaytekin committed Nov 15, 2023
1 parent 6a550ba commit cfbacd9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
15 changes: 13 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"express-hbs": "~2.4.0",
"http-headers": "~3.0.2",
"kleur": "~4.1.4",
"lodash.groupby": "^4.6.0",
"lodash.groupby": "~4.6.0",
"lodash.keys": "~4.2.0",
"moment": "~2.29.4",
"morgan": "~1.10.0",
"nanoid": "~3.3.2",
Expand Down
3 changes: 2 additions & 1 deletion view/presenter/result-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'use strict';

const groupBy = require('lodash/groupBy');
const keys = require('lodash/keys');
const moment = require('moment');

module.exports = presentResultList;
Expand All @@ -24,7 +25,7 @@ function presentResultList(results) {
return moment(result.date).format('YYYY-MM-DD');
});
const uniqueDayResults = [];
_.keys(resultsByDay).forEach(day => {
keys(resultsByDay).forEach(day => {
uniqueDayResults.push(resultsByDay[day][0]);
});
return uniqueDayResults;
Expand Down
5 changes: 3 additions & 2 deletions view/presenter/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'use strict';

const groupBy = require('lodash/groupBy');
const keys = require('lodash/keys');
const presentIgnoreRules = require('./ignore');
const techs = require('../../data/techniques')();

Expand All @@ -39,8 +40,8 @@ function presentResult(result) {
['error', 'warning', 'notice'].forEach(type => {
const pluralType = `${type}s`;
const results = groupedByType[type] || [];
const groupedByCode = _.groupBy(results, 'code');
result[pluralType] = _.keys(groupedByCode).map(group => {
const groupedByCode = groupBy(results, 'code');
result[pluralType] = keys(groupedByCode).map(group => {
const groupMessage = groupedByCode[group][0];
groupMessage.count = groupedByCode[group].length;
groupMessage.items = groupedByCode[group].map(plural => ({
Expand Down

0 comments on commit cfbacd9

Please sign in to comment.