Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce redundancy in transcript #2280

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d3a5460
reduce redundancy in transcript
Jun 5, 2024
c99ace9
edited code by Amos
Jun 6, 2024
2c16131
using array to store job_title data instead of using variavble
Jun 7, 2024
76e7c0f
sorting experience elements by alphabetical order and end date
Jun 10, 2024
6d7cf86
Sorting experience elements by alphabetical order and end date. Delet…
Jun 10, 2024
5936f8c
Complete the code to job titles and end date.
Jun 11, 2024
7b16a93
Delete console.log
Jun 11, 2024
e9ae5c9
Apply suggestions from code review
yushinj Jun 12, 2024
4ea5b62
Merge branch 'develop' into s24-remove-redundancy-transcript
amos-cha Jun 12, 2024
8b4083c
Alppy suggestions from code review and improve legibility of transcripts
Jun 12, 2024
e74e80c
Merge branch 's24-remove-redundancy-transcript' of https://github.com…
Jun 12, 2024
06b2b18
Merge branch 'develop' into s24-remove-redundancy-transcript
amos-cha Jun 13, 2024
1b9fb91
Apply suggestions from code review
yushinj Jun 13, 2024
189c110
apply suggestion from code reivew except groupedExperience
Jun 14, 2024
df1143d
Merge branch 'develop' into s24-remove-redundancy-transcript
Jun 25, 2024
1ac3f23
Create grouped experience by Job_Title and sort them by the lastes en…
Jul 2, 2024
0af2330
ignore
Jul 8, 2024
b20f130
ignore
Jul 9, 2024
2e60437
display grouped and sorted transcript
Jul 11, 2024
c8fabde
delete unsed code and add comment
Jul 11, 2024
ad4d617
add comments
Jul 12, 2024
fcd8079
fix some errors
Jul 12, 2024
67a68cc
fix some errors
Jul 12, 2024
cf20b05
update ts
Jul 12, 2024
a21c1b3
Update package.json
yushinj Jul 12, 2024
ac6ce86
restore unrelated changes
Jul 12, 2024
53c4711
Merge branch 's24-remove-redundancy-transcript' of https://github.com…
Jul 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 81 additions & 3 deletions src/services/transcript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export type TranscriptItems = {
activities: MembershipHistory[];
};

export type Groupexperience = {
Job_Title: string;
job: StudentEmployment[] | undefined;
latestDate?: string;
};

const getItems = (username: string) =>
Promise.all([
userService.getMembershipHistory(username),
Expand Down Expand Up @@ -50,7 +56,7 @@ const getItems = (username: string) =>
const categorizeItems = async (memberships: MembershipHistory[], jobs: StudentEmployment[]) => {
const groupedMembershipHistory: TranscriptItems = {
honors: [] as MembershipHistory[],
experiences: jobs as (MembershipHistory | StudentEmployment)[],
experiences: jobs as StudentEmployment[],
service: [] as MembershipHistory[],
activities: [] as MembershipHistory[],
};
Expand All @@ -70,10 +76,71 @@ const categorizeItems = async (memberships: MembershipHistory[], jobs: StudentEm

groupedMembershipHistory.activities = memberships;

groupedMembershipHistory.experiences.sort(
(a, b) => getExperienceEndDate(b) - getExperienceEndDate(a),
// Sort experiences by experience name then by end date
groupedMembershipHistory.experiences.sort((a, b) => {
const nameComparison = getName(a).localeCompare(getName(b));
return nameComparison !== 0
? nameComparison
: getExperienceEndDate(b) - getExperienceEndDate(a);
});

//groupedMembershipHistory.experiences = jobs;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//groupedMembershipHistory.experiences = jobs;

remove unused code


let GroupByTitle = Object.entries(Object.groupBy(jobs, (job) => job.Job_Title)).map(
([title, job]) => ({
Job_Title: title,
job,
latestDate: '',
}),
);

// This code is has a lot of ? and ! opeators because typescript can't analyze the
// loop to recognize that the array indexing is safe.
for (let i = 0; i < GroupByTitle.length; i++) {
let maxDate: string = '';
let tempJob = GroupByTitle?.[i].job;
let numJobs = tempJob!.length;
for (let j = 0; j < numJobs; j++) {
let tempVal = GroupByTitle[i];
let value = tempVal!.job?.[j].Job_End_Date;
if (maxDate! < value!) {
maxDate = value!;
}
}
GroupByTitle[i].latestDate = maxDate;
}

// Sorting the grouped job by the latest end date
GroupByTitle.sort((a, b) => {
return getLatestEndDate(b)! - getLatestEndDate(a)!;
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return this new GroupByTitle in groupedMembershipHistory, NOT the de-grouped version below. (Why do all the work to combine each job into one entry with multiple times, and then not use it?)


console.log(GroupByTitle);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log(GroupByTitle);

remove console logs


let test = [];
for (let i = 0; i < GroupByTitle.length; i++) {
let tempJob = GroupByTitle?.[i].job;
let numJobs = tempJob!.length;
for (let j = 0; j < numJobs; j++) {
let tempVal = GroupByTitle[i];
let value = tempVal!.job?.[j];
if (j > 0) {
value!.Job_Title = '';
}
if (value) {
test.push(value);
}
}
}

for (let i = 0; i < test.length; i++) {
jobs[i] = test[i];
}
Comment on lines +133 to +151
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be deleted.


//console.log('jobs');
//console.log(jobs);
//console.log('groupedMembershipHistory');
//console.log(groupedMembershipHistory);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//console.log('jobs');
//console.log(jobs);
//console.log('groupedMembershipHistory');
//console.log(groupedMembershipHistory);

Remove unused consolelogs

return groupedMembershipHistory;
};

Expand Down Expand Up @@ -141,3 +208,14 @@ const transcriptService = {
};

export default transcriptService;

const getName = (experience: MembershipHistory | StudentEmployment) =>
'Sessions' in experience ? experience.ActivityCode : experience.Job_Title;

const getLatestEndDate = (GroupByTitle: Groupexperience) => {
const date = GroupByTitle.latestDate;

if (date) {
return Date.parse(date);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@
grid-row: 1;
text-align: left;
}
}

@media print {
.experience_transcript_activities {
grid-row-gap: 0px;
@media print {
.experience_transcript_activities {
grid-row-gap: 20px;
}
}
}

.empty_title {
position: relative;
grid-row-gap: 5px;
top: -15px;
}
28 changes: 21 additions & 7 deletions src/views/CoCurricularTranscript/Components/Experience/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ type Props = {
Experience: StudentEmployment;
};

const Experience = ({ Experience }: Props) => (
<div className={styles.experience_transcript_activities}>
<div className={styles.organization_role}>
{Experience.Job_Department_Name}, {Experience.Job_Title}
const Experience = ({ Experience }: Props) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be simpler if you passed in the grouped jobs.

const jobTitles = newJobTitle(Experience);
return (
<div
className={
jobTitles === ''
? `${styles.experience_transcript_activities} ${styles.empty_title}`
: styles.experience_transcript_activities
}
>
<div className={styles.organization_role}>{jobTitles}</div>
<div className={styles.date}> {formatDuration(Experience)} </div>
</div>
<div className={styles.date}> {formatDuration(Experience)} </div>
</div>
);
);
};

const formatDuration = ({ Job_Start_Date, Job_End_Date }: StudentEmployment) => {
if (!Job_Start_Date) {
Expand All @@ -35,4 +42,11 @@ const formatDuration = ({ Job_Start_Date, Job_End_Date }: StudentEmployment) =>
}
};

const newJobTitle = ({ Job_Department_Name, Job_Title }: StudentEmployment) => {
if (Job_Title === '') {
return '';
}
return Job_Title === '' ? Job_Title : `${Job_Department_Name}, ${Job_Title}`;
Comment on lines +46 to +49
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (Job_Title === '') {
return '';
}
return Job_Title === '' ? Job_Title : `${Job_Department_Name}, ${Job_Title}`;
if (Job_Title === '') {
return '';
}
return Job_Title === '' ? Job_Title : `${Job_Department_Name}, ${Job_Title}`;

that top part and the first half of the ternary are logically identical. Is there a reason both are included?

};

export default Experience;
Loading