-
Notifications
You must be signed in to change notification settings - Fork 5
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
time_json에 실제 시간 추가 #231
time_json에 실제 시간 추가 #231
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ import InvalidLectureTimeJsonError from '../../lecture/error/InvalidLectureTimeJ | |
|
||
var logger = winston.loggers.get('default'); | ||
|
||
export function timeAndPlaceToJson(timesString: string, locationsString: string): TimePlace[] { | ||
export function timeAndPlaceToJson(timesString: string, locationsString: string, realTimesString: string): TimePlace[] { | ||
try { | ||
// 시간 정보가 없다면 빈 정보를 반환한다. | ||
if (timesString === '') { | ||
|
@@ -15,6 +15,7 @@ export function timeAndPlaceToJson(timesString: string, locationsString: string) | |
|
||
let locations = locationsString.split('/'); | ||
let times = timesString.split('/'); | ||
let realTimes = realTimesString.split('/') | ||
|
||
// 만약 강의실이 하나 뿐이거나 없다면, 시간에 맞춰서 강의 장소를 추가해준다. | ||
if (locations.length != times.length) { | ||
|
@@ -31,15 +32,20 @@ export function timeAndPlaceToJson(timesString: string, locationsString: string) | |
} | ||
} | ||
|
||
let classes = times.map((time, idx) => { | ||
let classes = times.map((time, idx) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 친구도 혹시 const 안 되나여? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 마찬가쥐 |
||
let timeSplitted = time.split('-'); | ||
const parsedRealTimes = realTimes[idx].match(/\d{2}:\d{2}/g) | ||
const startTime = parsedRealTimes[0] | ||
const endTime = parsedRealTimes[1] | ||
let day = ['월', '화', '수', '목', '금', '토', '일'].indexOf(timeSplitted[0].charAt(0)); | ||
let start = Number(timeSplitted[0].slice(2)); | ||
let len = Number(timeSplitted[1].slice(0, -1)); | ||
let place = locations[idx]; | ||
return { | ||
day, | ||
start, | ||
start_time: startTime, | ||
end_time: endTime, | ||
len, | ||
place | ||
}; | ||
|
@@ -63,11 +69,13 @@ export function timeAndPlaceToJson(timesString: string, locationsString: string) | |
|
||
// Merge same time with different location | ||
// Merge continuous time with same location | ||
// TODO: 연속된 강의 머지기능 유지 논의 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이건 어떤 의미에요? 관련 쓰레드 던져놔주셔도 좋음 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 한 강의가 같은 강의실에서 연속된 시간에 존재하면 머지하는 로직이 있어요 |
||
for (let i = 1; i < classes.length; i++) { | ||
let prev = classes[i-1]; | ||
let curr = classes[i]; | ||
if (prev.day == curr.day && prev.place == curr.place && curr.start == (prev.start + prev.len)) { | ||
prev.len += curr.len; | ||
prev.end_time = curr.end_time | ||
classes.splice(i--, 1); | ||
} else if (prev.day == curr.day && prev.start == curr.start && prev.len == curr.len) { | ||
prev.place += '/' + curr.place; | ||
|
@@ -77,7 +85,7 @@ export function timeAndPlaceToJson(timesString: string, locationsString: string) | |
return classes; | ||
} catch (err) { | ||
logger.error(err); | ||
logger.error("Failed to parse timePlace (times: " + timesString + ", locations: " + locationsString + ")"); | ||
logger.error("Failed to parse timePlace (times: " + timesString + ", locations: " + locationsString + ", realTime: " + realTimesString + ")"); | ||
return []; | ||
} | ||
} | ||
|
@@ -130,4 +138,4 @@ export function timeJsonToMask(timeJson:Array<TimePlace>, duplicateCheck?:boolea | |
timeMasks.push(mask); | ||
} | ||
return timeMasks; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ describe("SugangSnuLectureServiceIntegrationTest", function() { | |
course_title: '그린리더십 인턴십', | ||
credit: 3, | ||
class_time: '금(6-3)', | ||
class_time_json: [ { day: 4, start: 6, len: 3, place: '220-202' } ], | ||
class_time_json: [ { day: 4, start: 6, len: 3, place: '220-202', start_time: '14:00', end_time: '16:50' } ], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 PR 에 어울리는 얘기는 아니지만, KST 기준으로 DB 에 저장하는 거 당연히 괜찮은 선택이겠죠? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넹 스트링으로 저장해서 일단은 |
||
class_time_mask: [ 0, 0, 0, 0, 258048, 0, 0 ], | ||
instructor: '류재명', | ||
quota: 40, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
뒤에서 변경 없으면 const 쓰면 어떨까요? + 강박적으로 지킬 필욘 없지만 보여서 언급하자면 위 라인에서 마지막 ; 찍어줘도 좋을 듯 합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 그냥 기존에 있던 코드는 냅뒀어요ㅋㅋ
다 const로 바꿔버릴까 하다가 그냥 한도 끝도 없을 것 같아서..