-
Notifications
You must be signed in to change notification settings - Fork 1
[Feat-T3-203] 제보 히스토리 API 연동 #72
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
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 |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // | ||
| // ReportDictonaryDTO.swift | ||
| // DataSource | ||
| // | ||
| // Created by 최정인 on 11/21/25. | ||
| // | ||
|
|
||
| struct ReportDictonaryDTO: Decodable { | ||
| let reportInfos: [String: [ReportDTO]] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,13 +12,13 @@ import Foundation | |
| final class ReportHistoryViewModel: ViewModel { | ||
| enum Input { | ||
| case fetchReports | ||
| case fetchReport(index: Int) | ||
| case filterCategory(type: ReportType) | ||
| case filterProgress(progress: ReportProgress) | ||
| } | ||
|
|
||
| struct Output { | ||
| let progressPublisher: AnyPublisher<[ReportProgressItem], Never> | ||
| let selectedProgressPublisher: AnyPublisher<ReportProgress?, Never> | ||
| let categoryPublisher: AnyPublisher<[ReportType], Never> | ||
| let selectedCategoryPublisher: AnyPublisher<ReportType?, Never> | ||
| let reportsPublisher: AnyPublisher<[ReportHistoryItem], Never> | ||
|
|
@@ -27,14 +27,17 @@ final class ReportHistoryViewModel: ViewModel { | |
|
|
||
| private(set) var output: Output | ||
| private let progressSubject = CurrentValueSubject<[ReportProgressItem], Never>([]) | ||
| private let selectedProgressSubject = CurrentValueSubject<ReportProgress?, Never>(nil) | ||
| private let categorySubject = CurrentValueSubject<[ReportType], Never>([]) | ||
| private let selectedCategorySubject = CurrentValueSubject<ReportType?, Never>(nil) | ||
| private let reportSubject = CurrentValueSubject<[ReportHistoryItem], Never>([]) | ||
| private let selectedReportSubject = PassthroughSubject<Int?, Never>() | ||
| private(set) var selectedReportCategory: ReportType? | ||
| private var reports: [ReportHistoryItem] = [] | ||
| private let reportRepository: ReportRepositoryProtocol | ||
|
|
||
| init() { | ||
| init(reportRepository: ReportRepositoryProtocol) { | ||
| self.reportRepository = reportRepository | ||
| progressSubject | ||
| .send( | ||
| ReportProgress.allCases.map { ReportProgressItem( | ||
|
|
@@ -46,6 +49,7 @@ final class ReportHistoryViewModel: ViewModel { | |
|
|
||
| output = Output( | ||
| progressPublisher: progressSubject.eraseToAnyPublisher(), | ||
| selectedProgressPublisher: selectedProgressSubject.eraseToAnyPublisher(), | ||
| categoryPublisher: categorySubject.eraseToAnyPublisher(), | ||
| selectedCategoryPublisher: selectedCategorySubject.eraseToAnyPublisher(), | ||
| reportsPublisher: reportSubject.eraseToAnyPublisher(), | ||
|
|
@@ -56,8 +60,6 @@ final class ReportHistoryViewModel: ViewModel { | |
| switch input { | ||
| case .fetchReports: | ||
| fetchReports() | ||
| case .fetchReport(let index): | ||
| fetchReport(index: index) | ||
| case .filterCategory(let type): | ||
| filterCategory(reportType: type) | ||
| case .filterProgress(let progress): | ||
|
|
@@ -99,16 +101,42 @@ final class ReportHistoryViewModel: ViewModel { | |
| } | ||
|
|
||
| private func filterReports() { | ||
| let selectedProgress = selectedProgressSubject.value | ||
| let selectedCategory = selectedCategorySubject.value | ||
|
|
||
| var filteredReports = reports | ||
| if let selectedProgress { | ||
| filteredReports = filteredReports.filter({ $0.progress == selectedProgress }) | ||
| } | ||
| if let selectedCategory { | ||
| filteredReports = filteredReports.filter({ $0.type == selectedCategory }) | ||
| } | ||
| reportSubject.send(filteredReports) | ||
| } | ||
|
Comment on lines
103
to
115
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. 🧩 Analysis chain필터링 로직의 잠재적 문제를 확인하세요. 현재 구현에서 다음 스크립트로 🏁 Script executed: #!/bin/bash
# selectedProgressSubject.send 호출을 찾아 올바르게 업데이트되는지 확인
rg -n "selectedProgressSubject\.send" --type swiftLength of output: 0 추가 검증이 필요합니다. 🏁 Script executed: #!/bin/bash
# selectedProgressSubject의 모든 사용 위치 확인
rg -n "selectedProgressSubject" --type swift -B2 -A2Length of output: 2071 🏁 Script executed: #!/bin/bash
# filterProgress 메서드 존재 여부 확인
rg -n "filterProgress" --type swift -B2 -A2Length of output: 2222 🏁 Script executed: #!/bin/bash
# ReportHistoryViewModel.swift 파일의 전체 내용 확인
find . -name "ReportHistoryViewModel.swift" -type f | head -1 | xargs catLength of output: 5081
결과적으로 수정: 🤖 Prompt for AI Agents
Collaborator
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. @taipaise 확인해 주셔서 감사합니다! 오늘 작업에서 |
||
|
|
||
| private func fetchReports() { | ||
| //reportSubject.send(ReportHistoryItem.dummyData) | ||
| } | ||
|
|
||
| private func fetchReport(index: Int) { | ||
| guard index < reports.count else { return } | ||
|
|
||
| selectedReportSubject.send(reports[index].id) | ||
| Task { | ||
| do { | ||
| let reportEntities = try await reportRepository.fetchReports() | ||
|
|
||
| var reportHistoryItems: [ReportHistoryItem] = [] | ||
| for reportEntity in reportEntities { | ||
| let reportHistoryItem = ReportHistoryItem( | ||
| id: reportEntity.id, | ||
| title: reportEntity.title, | ||
| thumbnailUrl: reportEntity.photoUrls.first ?? "", | ||
| date: reportEntity.date ?? "", | ||
| type: reportEntity.type, | ||
| progress: reportEntity.progress, | ||
| location: reportEntity.location.address ?? "") | ||
| reportHistoryItems.append(reportHistoryItem) | ||
| } | ||
|
|
||
| reports = reportHistoryItems | ||
| reportSubject.send(reportHistoryItems) | ||
| } catch { | ||
| // TODO: 에러 처리 | ||
| } | ||
| } | ||
| } | ||
| } | ||
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.
파일명과 타입명의 오타를 수정하세요.
파일명
ReportDictonaryDTO.swift와 구조체명ReportDictonaryDTO에 오타가 있습니다. "Dictonary"는 "Dictionary"로 수정되어야 합니다.다음과 같이 수정하세요:
ReportDictionaryDTO.swift로 변경ReportDictionaryDTO로 변경ReportRepository.swiftLine 19,ReportEndpoint.swift)🤖 Prompt for AI Agents