Skip to content
This repository has been archived by the owner on Oct 23, 2020. It is now read-only.

Commit

Permalink
build: subject parser
Browse files Browse the repository at this point in the history
  • Loading branch information
mu-hun committed Nov 14, 2019
1 parent ac22ca4 commit 03222ae
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 29 deletions.
65 changes: 43 additions & 22 deletions src/@types/dreamy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,45 @@ type point =
| 0.7
| 0.0

export type gradePoint =
| 'A+'
| 'A0'
| 'A-'
| 'B+'
| 'B0'
| 'B-'
| 'C+'
| 'C0'
| 'C-'
| 'D+'
| 'D0'
| 'D-'
| 'F'

export enum grade {
'A+' = 4.3,
'A0' = 4.0,
'A-' = 3.7,
'B+' = 3.3,
'B0' = 3.0,
'B-' = 2.7,
'C+' = 2.3,
'C0' = 2.0,
'C-' = 2.7,
'D+' = 2.3,
'D0' = 1.0,
'D-' = 0.7,
'F' = 0,
}

export type course =
| '기초교양'
| '전공탐색'
| '전인교양'
| '전공선택'
| '전공필수'
| '일반선택'

type tUnivs =
| '인문대학'
| '사회과학대학'
Expand All @@ -37,34 +76,16 @@ type tUnivs =

export interface gradeSet {
credit: 0 | 2 | 3 | 4
dg_gb:
| 'A+'
| 'A0'
| 'A-'
| 'B+'
| 'B0'
| 'B-'
| 'C+'
| 'C0'
| 'C-'
| 'D+'
| 'D0'
| 'D-'
| 'F'
dg_gb: gradePoint
isu_cd:
| 'A.기초교양'
| 'B.전공탐색'
| 'T.전인교양'
| 'L.전공선택'
| 'D.전공필수'
| 'G.일반선택'
isu_nm:
| '기초교양'
| '전공탐색'
| '전인교양'
| '전공선택'
| '전공필수'
| '일반선택'
isu_nm: course

mark: point
rownum: tRowCount
subject_cd: string // 과목 코드
Expand Down Expand Up @@ -133,6 +154,6 @@ interface total_grade_summery extends parent_grade_props {
}

export type PostprocessedItem = {
GRID_DATA: grade[]
GRID_DATA: gradeSet[]
BOTTOM_DATA: current_searched_grade_summary
}
10 changes: 10 additions & 0 deletions src/@types/models.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import { gradePoint, course } from './dreamy'

export interface TypeUserNoPw {
student_no: number
student_pw: string
}

type Subject = {
title: string
code: string
grade: gradePoint
type: course
}

export type TypeSemester = {
subject: Subject[]
averagePoint: number // Float
totalCredit: number
isOutside: boolean
Expand Down
26 changes: 19 additions & 7 deletions src/utils/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,20 +172,32 @@ export const fetchAndParse = async (account: TypeUserNoPw) => {

const semesters = fetchedSemester.map(
({
GRID_DATA,
BOTTOM_DATA: {
avg_mark: averagePoint,
apply_credit: totalCredit,
term_gb,
year,
outside_gb,
},
}) => ({
averagePoint,
totalCredit,
isOutside: !!outside_gb,
semester: enumSemester[semesterNumStr[term_gb]],
year,
})
}) => {
const subject = GRID_DATA.map(
({
subject_nm: title,
subject_cd: code,
dg_gb: grade,
isu_nm: type,
}) => ({ title, code, grade, type })
)
return {
subject,
averagePoint,
totalCredit,
isOutside: !!outside_gb,
semester: enumSemester[semesterNumStr[term_gb]],
year,
}
}
)
return { name, averagePoint, semesters }
}

0 comments on commit 03222ae

Please sign in to comment.