Skip to content

Commit

Permalink
[#1973] Remove redundant User class (#2093)
Browse files Browse the repository at this point in the history
Remove utils/user.ts, replace with User interface from types.ts

The User class and interface are equivalent in their usage and their
redundancy seems to be a remnant when the code was migrated from JS to
TS.

Let's remove the User class for consistency and to improve runtime
performance.
  • Loading branch information
jonasongg committed Jan 26, 2024
1 parent 54ba5ec commit 6481806
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 56 deletions.
7 changes: 3 additions & 4 deletions frontend/src/components/c-ramp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@
</template>

<script lang='ts'>
import { defineComponent } from 'vue';
import { defineComponent, PropType } from 'vue';
import brokenLinkDisabler from '../mixin/brokenLinkMixin';
import User from '../utils/user';
import { Commit, CommitResult } from '../types/types';
import { Commit, CommitResult, User } from '../types/types';
export default defineComponent({
name: 'c-ramp',
Expand All @@ -49,7 +48,7 @@ export default defineComponent({
default: 'groupByRepos',
},
user: {
type: User,
type: Object as PropType<User>,
required: true,
},
tframe: {
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/types/vuex.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Store } from 'vuex';
import { AuthorshipFile } from './types';
import User from '../utils/user';
import { AuthorshipFile, User } from './types';

interface AuthorshipInfo {
author: string;
Expand Down
7 changes: 3 additions & 4 deletions frontend/src/types/window.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import JSZip from 'jszip';
import User from '../utils/user';
import { Repo, User as UserType } from './types';
import { Repo, User } from './types';
import { AuthorshipSchema } from './zod/authorship-type';
import { AuthorDailyContributions } from './zod/commits-type';
import { DomainUrlMap, ErrorMessage } from './zod/summary-type';
Expand Down Expand Up @@ -61,8 +60,8 @@ declare global {
getCommitLink: (repoId: string, commitHash: string) => string | undefined;
getBlameLink: (repoId: string, branch: string, filepath: string) => string | undefined;
getHistoryLink: (repoId: string, branch: string, filepath: string) => string | undefined;
getGroupName: (group: UserType[], filterGroupSelection: string) => string;
getAuthorDisplayName: (authorRepos: UserType[]) => string;
getGroupName: (group: User[], filterGroupSelection: string) => string;
getAuthorDisplayName: (authorRepos: User[]) => string;
api: Api;
sinceDate: string;
untilDate: string;
Expand Down
7 changes: 3 additions & 4 deletions frontend/src/utils/api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { DailyCommit, CommitResult } from '../types/types';
import { DailyCommit, CommitResult, User } from '../types/types';
import { authorshipSchema } from '../types/zod/authorship-type';
import { commitsSchema } from '../types/zod/commits-type';
import { ErrorMessage, summarySchema } from '../types/zod/summary-type';
import User from './user';

// utility functions //
window.$ = (id) => document.getElementById(id);
Expand Down Expand Up @@ -258,7 +257,7 @@ window.api = {
];

// commits and checkedFileTypeContribution are set in c-summary
const user = new User({
const user: User = {
name: author,
repoId: repoName,
variance: commits.authorContributionVariance[author],
Expand All @@ -270,7 +269,7 @@ window.api = {
repoName: `${repo.displayName}`,
location: `${repo.location.location}`,
checkedFileTypeContribution: undefined,
});
};

res.push(user);
}
Expand Down
40 changes: 0 additions & 40 deletions frontend/src/utils/user.ts

This file was deleted.

4 changes: 2 additions & 2 deletions frontend/src/views/c-zoom.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ import brokenLinkDisabler from '../mixin/brokenLinkMixin';
import tooltipPositioner from '../mixin/dynamicTooltipMixin';
import cRamp from '../components/c-ramp.vue';
import cStackedBarChart from '../components/c-stacked-bar-chart.vue';
import User from '../utils/user';
import {
Bar,
Commit,
CommitResult,
DailyCommit,
WeeklyCommit,
User,
} from '../types/types';
import CommitsSortType from '../types/zoom';
import { StoreState } from '../types/vuex.d';
Expand Down Expand Up @@ -237,7 +237,7 @@ export default defineComponent({
}
tempUser.commits.push(newCommit);
});
return new User(tempUser);
return tempUser;
},
selectedCommits(): Commit[] {
Expand Down

0 comments on commit 6481806

Please sign in to comment.