Skip to content

Commit

Permalink
Merge pull request #123 from TeamHY2/Fix/#119-Calendar_StudyRecord
Browse files Browse the repository at this point in the history
[Fix] 캘린더에 공부기록이 나타나지 않는현상 수정합니다.
  • Loading branch information
Seokki-Kwon authored Dec 3, 2024
2 parents 0dd0717 + b2ca847 commit 48abc9b
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 14 deletions.
4 changes: 2 additions & 2 deletions HongikYeolgong2.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.1.1;
MARKETING_VERSION = 1.1.3;
PRODUCT_BUNDLE_IDENTIFIER = com.teamHY2.HongikYeolgong2;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -1603,7 +1603,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.1.1;
MARKETING_VERSION = 1.1.3;
PRODUCT_BUNDLE_IDENTIFIER = com.teamHY2.HongikYeolgong2;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ final class StudySessionRepositoryImpl: StudySessionRepository {
return Future<[AllStudyRecord], NetworkError> { promise in
Task {
do {
let response: BaseResponse<[CalendarCountAllResponseDTO]> = try await NetworkService.shared.request(endpoint: WeeklyEndpoint.getAllStudyRecords)
let response: BaseResponse<[CalendarCountAllResponseDTO]> = try await NetworkService.shared.request(endpoint: WeeklyEndpoint.getAllStudyRecords)
promise(.success(response.data.map { $0.toEntity() }))

} catch let error as NetworkError {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class StudySessionInteractorImpl: StudySessionInteractor {
private let cancleBag = CancelBag()
private let studySessionRepository: StudySessionRepository
private let timer = Timer.publish(every: 1.0, on: .main, in: .common).autoconnect()
private let addedTime: TimeInterval = .init(hours: 6)
private let addedTime: TimeInterval = .init(hours: 4)

private var lastTime: Date?
private var subscription: AnyCancellable?
Expand Down
6 changes: 5 additions & 1 deletion HongikYeolgong2/Domain/Mapper/CalendarMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import Foundation

extension CalendarCountAllResponseDTO {
func toEntity() -> AllStudyRecord {
.init(day: date.toDayofDate(), month: date.toMonthofDate(), year: date.toYearofDate(), date: date.toDate() ?? Date.now, studyCount: studyCount)
.init(day: date.toDayofDate(),
month: date.toMonthofDate(),
year: date.toYearofDate(),
date: date.toDate() ?? Date.now,
studyCount: studyCount)
}
}
2 changes: 1 addition & 1 deletion HongikYeolgong2/Domain/Mapper/StudySessionMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ extension WeeklyStudySessionDTO {
func toEntity() -> WeeklyStudyRecord {
.init(monthOfDay: date,
studyCount: studyCount,
isUpcomming: date.toDate() ?? .now <= .now)
isUpcomming: date.toDateFromMonthDay() ?? .now <= .now)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct CaledarView: View {
Spacer()
}
.onAppear {
calendarDataInteractor.getAllStudy(studyRecords: $AllStudy)
calendarDataInteractor.getAllStudy(studyRecords: $AllStudy)
currentMonth = makeMonth(date: seletedDate, roomUsageInfo: AllStudy)
}
.onChange(of: AllStudy) { newAllStudy in
Expand Down Expand Up @@ -199,7 +199,5 @@ extension CaledarView {

currentMonth = makeMonth(date: seletedDate, roomUsageInfo: AllStudy)
}

}


20 changes: 15 additions & 5 deletions HongikYeolgong2/Util/Extensions/String+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,24 @@ extension String {
}()

/// 문자열 형식의 날짜를 Date 객체로 변환합니다.
/// - Returns: Date
func toDate() -> Date? {
let dateFormatter = Self.dateFormatter
/// - Returns: Date
func toDate() -> Date? {
let dateFormatter = Self.dateFormatter
guard let date = dateFormatter.date(from: self) else {
return nil
}
return date
}

func toDateFromMonthDay() -> Date? {
let dateFormatter = DateFormatter()
let currentYear = Calendar.current.component(.year, from: Date())

dateFormatter.dateFormat = "M/dd"
guard let date = dateFormatter.date(from: self) else {
return nil
}

var components = Calendar.current.dateComponents([.year, .month, .day], from: date)
components.year = currentYear

Expand Down Expand Up @@ -60,3 +68,5 @@ extension String {
return "\(year)"
}
}


0 comments on commit 48abc9b

Please sign in to comment.