Skip to content

Commit

Permalink
Feature: Use first column as default sort
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelmhtr committed Dec 12, 2024
1 parent 9e22ee2 commit 5eb3d4f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42757,7 +42757,8 @@ module.exports = ({
displayCharts,
}) => {
const execute = () => {
const sorted = applyLimit(sortByStats(entries, sortBy), limit);
const sortByStat = sortBy || mainStats[0];
const sorted = applyLimit(sortByStats(entries, sortByStat), limit);
const bests = calculateBests(sorted);

return getTableData({
Expand Down Expand Up @@ -43022,12 +43023,15 @@ module.exports = async ({
}) => {
const users = await getUsers(pulls, { excludeStr });
core.info(`Found ${users.length} collaborators to analyze`);
core.debug(JSON.stringify(users, null, 2));

const pullRequestStats = getPullRequestStats(pulls);
core.info(`Analyzed stats for ${pullRequestStats.length} authors`);
core.debug(JSON.stringify(pullRequestStats, null, 2));

const reviewStats = getReviewStats(pulls);
core.info(`Analyzed stats for ${reviewStats.length} reviewers`);
core.debug(JSON.stringify(reviewStats, null, 2));

return fulfillEntries(
mergeStats({ users, pullRequestStats, reviewStats }),
Expand Down
3 changes: 2 additions & 1 deletion src/interactors/__tests__/getEntries.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jest.mock('../getUsers', () => jest.fn());
jest.mock('../mergeStats', () => jest.fn());

describe('Interactors | .getEntries', () => {
const core = { info: jest.fn() };
const core = { info: jest.fn(), debug: jest.fn() };
const pulls = ['PULL1', 'PULL2', 'PULL3'];
const entries = ['ENTRY1', 'ENTRY2', 'ENTRY3'];
const merged = 'MERGED';
Expand Down Expand Up @@ -41,5 +41,6 @@ describe('Interactors | .getEntries', () => {
expect(mergeStats).toBeCalledWith({ users, pullRequestStats, reviewStats });
expect(fulfillEntries).toBeCalledWith(merged, { periodLength: params.periodLength });
expect(core.info).toHaveBeenCalledTimes(3);
expect(core.debug).toHaveBeenCalledTimes(3);
});
});
3 changes: 2 additions & 1 deletion src/interactors/buildTable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ module.exports = ({
displayCharts,
}) => {
const execute = () => {
const sorted = applyLimit(sortByStats(entries, sortBy), limit);
const sortByStat = sortBy || mainStats[0];
const sorted = applyLimit(sortByStats(entries, sortByStat), limit);
const bests = calculateBests(sorted);

return getTableData({
Expand Down
3 changes: 3 additions & 0 deletions src/interactors/getEntries.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ module.exports = async ({
}) => {
const users = await getUsers(pulls, { excludeStr });
core.info(`Found ${users.length} collaborators to analyze`);
core.debug(JSON.stringify(users, null, 2));

const pullRequestStats = getPullRequestStats(pulls);
core.info(`Analyzed stats for ${pullRequestStats.length} authors`);
core.debug(JSON.stringify(pullRequestStats, null, 2));

const reviewStats = getReviewStats(pulls);
core.info(`Analyzed stats for ${reviewStats.length} reviewers`);
core.debug(JSON.stringify(reviewStats, null, 2));

return fulfillEntries(
mergeStats({ users, pullRequestStats, reviewStats }),
Expand Down

0 comments on commit 5eb3d4f

Please sign in to comment.