Skip to content

Commit

Permalink
education graphql removed
Browse files Browse the repository at this point in the history
  • Loading branch information
jmuzina committed Jan 13, 2024
1 parent 0455c6b commit fa1eb12
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 107 deletions.
47 changes: 18 additions & 29 deletions src/app/classes/education/Degree.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
import { IDegreeHonorOpts, IDegreeOpts, IDegreeTypeOpts } from 'src/app/interfaces/education/Degree';
import {
IDegreeHonorOpts,
IDegreeOpts,
IDegreeTypeOpts,
} from 'src/app/interfaces/education/Degree';
import { EducationalInstitution } from './EducationalInstitution';
import { Major } from './Major';
import { IEducationalField } from 'src/app/interfaces/education/EducationalField';
import { EducationalLevel } from './EducationalLevel';

export class DegreeHonor implements IDegreeHonorOpts {
id!: number;

label!: string;

constructor(opts: IDegreeHonorOpts) {
Object.assign(this, opts);
}
}
export class DegreeType implements IDegreeTypeOpts {
id!: number;

prefix!: string;

usesSuffixInline!: boolean;

level!: EducationalLevel;

export class DegreeType {
label!: string;

constructor(opts: IDegreeTypeOpts) {
Expand All @@ -48,6 +42,17 @@ export class Degree {

honor?: DegreeHonor;

constructor(opts: IDegreeOpts) {
this.gpa = opts.gpa;
this.startedOn = new Date(opts.started_on);
this.awardedOn = opts.awarded_on ? new Date(opts.awarded_on) : undefined;
this.institution = new EducationalInstitution(opts.institution);
this.major = opts.major;
this.honor = opts.honor;
this.type = new DegreeType(opts.type);
this.field = opts.field;
}

static Sort(a: Degree, b: Degree) {
const degreeTimestamps = {
a: {
Expand All @@ -68,11 +73,7 @@ export class Degree {
if (degreeTimestamps.a.start > degreeTimestamps.b.start) return -1;
if (degreeTimestamps.a.start < degreeTimestamps.b.start) return 1;

// award and start dates are identical, defer to educational level sort
const educationalLevelSortResult = EducationalLevel.Sort(a.type.level, b.type.level);
if (educationalLevelSortResult) return educationalLevelSortResult;

// Educational levels are also the same. Defer to educational institution sort.
// Defer to educational institution sort.
return EducationalInstitution.Sort(a.institution, b.institution);
}

Expand All @@ -87,16 +88,4 @@ export class Degree {
if (degreeTimestamps.a.end > degreeTimestamps.b.end) return -1;
return 1;
}

constructor(opts: IDegreeOpts) {
this.id = opts.id;
this.gpa = opts.gpa;
this.startedOn = new Date(opts.startedOn);
this.awardedOn = opts.awardedOn ? new Date(opts.awardedOn) : undefined;
this.institution = opts.institution;
this.major = opts.major;
this.field = opts.field;
this.type = opts.type;
this.honor = opts.honor;
}
}
25 changes: 9 additions & 16 deletions src/app/classes/education/EducationalInstitution.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
export interface IEducationalInstitutionType {
id: number;
label: string;
}
import { ILabelled } from '../../interfaces/Labelled';

export type EducationalInstitutionType = ILabelled;

export interface IEducationalInstitution {
id: number;
name: string;
institutionType: IEducationalInstitutionType;
type: ILabelled;
}

export class EducationalInstitution {
id!: number;

name!: string;

type!: IEducationalInstitutionType;
type!: EducationalInstitutionType;

constructor(opts: IEducationalInstitution) {
Object.assign(this, opts);
}

static Sort(a: EducationalInstitution, b: EducationalInstitution) {
if (a.name !== b.name) return a.name.localeCompare(b.name);
return a.type.label.localeCompare(b.type.label);
}

constructor(opts: IEducationalInstitution) {
this.id = opts.id;
this.name = opts.name;
this.type = opts.institutionType;
}

}
4 changes: 0 additions & 4 deletions src/app/classes/education/Major.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { IMajorOpts } from 'src/app/interfaces/education/Major';

export class Major implements IMajorOpts {
id!: number;

label!: string;

abbreviation!: string;

constructor(opts: IMajorOpts) {
Object.assign(this, opts);
}
Expand Down
2 changes: 0 additions & 2 deletions src/app/classes/employment/Job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { IJobOpts } from 'src/app/interfaces/employment/Job';
import moment from 'moment';

export class Responsibility implements IResponsibilityOpts {
id!: number;

text!: string;

constructor(opts: IResponsibilityOpts) {
Expand Down
27 changes: 26 additions & 1 deletion src/app/constants/education.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
import { IDegreeOpts } from '../interfaces/education/Degree';

export const degreeMappings: IDegreeOpts[] = [];
export const degreeMappings: IDegreeOpts[] = [
{
started_on: '2018-08-15T00:00:00+00:00',
awarded_on: '2022-05-20T00:00:00+00:00',
institution: {
name: 'Kent State University',
type: {
label: 'University',
},
},
type: {
label: 'Bachelor',
},
major: {
label: 'Computer Science',
},
field: {
label: 'Science',
suffix: 'S',
},
honor: {
label: 'Magna Cum Laude',
},
gpa: 3.86,
},
];
3 changes: 3 additions & 0 deletions src/app/interfaces/Labelled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface ILabelled {
label: string;
}
53 changes: 12 additions & 41 deletions src/app/interfaces/education/Degree.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,21 @@
import { EducationalInstitution } from 'src/app/classes/education/EducationalInstitution';
import { Major } from 'src/app/classes/education/Major';
import { IEducationalInstitution } from 'src/app/classes/education/EducationalInstitution';
import { IMajorOpts } from './Major';
import { ILabelled } from '../Labelled';
import { IEducationalField } from './EducationalField';
import { DegreeHonor, DegreeType } from 'src/app/classes/education/Degree';
import { EducationalLevel } from 'src/app/classes/education/EducationalLevel';

export interface IDegreeTypeOpts {
id: number;
prefix: string;
usesSuffixInline: boolean;
level: EducationalLevel;
label: string;
}

export interface IDegreeHonorOpts {
id: number;
label: string;
}
export type IDegreeTypeOpts = ILabelled;

export interface IDegreeTypeQryOpts {
id: number;
prefix: string;
usesSuffixInline: boolean;
education_level_fk: number;
label: string;
}
export type IDegreeHonorOpts = ILabelled;

export interface IDegreeQryOpts {
id: number;
gpa?: number;
startedOn: string;
awardedOn?: string;
institution_fk: number;
major_fk: number;
degree_field_fk: number;
degree_type_fk: number;
honor_fk?: number;
}
export type IDegreeFieldOpts = ILabelled;

export interface IDegreeOpts {
id: number;
gpa?: number;
startedOn: string;
awardedOn?: string;
institution: EducationalInstitution;
major: Major;
started_on: string;
awarded_on?: string;
institution: IEducationalInstitution;
major: IMajorOpts;
type: IDegreeTypeOpts;
field: IEducationalField;
type: DegreeType;
honor?: DegreeHonor;
honor?: IDegreeHonorOpts;
}
1 change: 0 additions & 1 deletion src/app/interfaces/education/EducationalField.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export interface IEducationalField {
id: number;
label: string;
suffix: string;
}
2 changes: 0 additions & 2 deletions src/app/interfaces/education/Major.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export interface IMajorOpts {
id: number;
label: string;
abbreviation: string;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
import { IAttributedResource } from 'src/app/interfaces/AttributedResource';
import { IAttributedResource } from '../../../../interfaces/AttributedResource';

@Component({
selector: 'jm-attribution',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
<div class="degree-detail flex flex-row">
<!-- <span class="primary-text">{{degree.type.prefix}}{{degree.type.usesSuffixInline ? degree.field.suffix : ''}}, {{degree.major.label}}</span> -->
<span class="secondary-text">Degree: </span>
<span class="primary-text">{{degree.type.label}} of {{degree.field.label}}, {{degree.major.label}}</span>
<span class="primary-text">{{ degree.type.label }} of {{ degree.field.label }}, {{ degree.major.label }}</span>
</div>
<div class="institution-detail flex flex-row">
<span class="secondary-text institution-type">{{degree.institution.type.label}}: </span>
<span class="primary-text institution-name">{{degree.institution.name}}</span>
<span class="secondary-text institution-type">{{ degree.institution.type.label }}: </span>
<span class="primary-text institution-name">{{ degree.institution.name }}</span>
<!-- <ng-container>
<span class="degree-status secondary-text"> (<span *ngIf="degree.awardedOn; else currentlyEnrolled" class="secondary-text">Class of {{degree.awardedOn | date : "y"}}</span><ng-template #currentlyEnrolled><span class="degree-currently-enrolled secondary-text">Currently enrolled</span></ng-template>)</span>
</ng-container> -->
</div>
<div class="graduation-status flex flex-row">
<span class="secondary-text">Graduation status: </span>
<span *ngIf="degree.awardedOn; else currentlyEnrolled" class="primary-text class-of-year">Class of {{degree.awardedOn | date : "y"}}</span>
<span *ngIf="degree.awardedOn; else currentlyEnrolled"
class="primary-text class-of-year">Class of {{ degree.awardedOn | date : "y" }}</span>
<ng-template #currentlyEnrolled>
<span class="primary-text currently-enrolled">Currently enrolled</span>
</ng-template>
</div>
<!-- <span class="degree-timeline">{{ degree.startedOn| date : "MMM y" }} -
{{ (degree.awardedOn| date : "MMM y") || "Present" }}</span> -->
<div class="degree-timeline">
<span *ngIf="degree.awardedOn" class="degree-c-o"></span>
</div>
<div class="degree-timeline">
<span *ngIf="degree.awardedOn" class="degree-c-o"></span>
</div>
<div *ngIf="degree.gpa" class="degree-gpa flex flex-row">
<span class="secondary-text degree-gpa-label">GPA: </span>
<span class="primary-text degree-gpa-value">{{degree.gpa}}</span>
<span *ngIf="degree.honor" class="primary-text degree-honor"> ({{degree.honor.label}})</span>
<span class="primary-text degree-gpa-value">{{ degree.gpa }}</span>
<span *ngIf="degree.honor" class="primary-text degree-honor"> ({{ degree.honor.label }})</span>
</div>
5 changes: 4 additions & 1 deletion src/app/services/education.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import { degreeMappings } from '../constants/education';

@Injectable({ providedIn: 'root' })
export class EducationService extends GenericService {
degrees: Degree[] = degreeMappings.map((opts) => new Degree(opts));
degrees: Degree[] = degreeMappings
.map((opts) => new Degree(opts))
.sort(Degree.Sort);

constructor() {
super();
console.log(this.degrees);
}
}

0 comments on commit fa1eb12

Please sign in to comment.