Skip to content
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

[Horizon] Feature/clx 165 notebook list #2995

Open
wants to merge 20 commits into
base: feature/horizon
Choose a base branch
from

Conversation

reabbotted
Copy link

  • Showing and filtering a list of courses that have notes by text search
  • Showing and filtering a list of notes for an individual course

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@inst-danger
Copy link
Contributor

inst-danger commented Dec 3, 2024

Horizon Build QR Code:

@inst-danger
Copy link
Contributor

inst-danger commented Dec 3, 2024

Warnings
⚠️ One or more files are below the minimum test coverage 50%
⚠️ The total test coverage is below the minimum 90%
Coverage New % Master % Delta
Canvas iOS 89.99% 90.05% -0.07%
Core/Core/Courses/CourseProgression/CDCourseProgression.swift 0% -- --
Core/Core/Planner/CalendarMain/ViewModel/PlannerViewModel.swift 0% 0% 0%
Core/Core/Planner/CalendarMain/Model/CalendarWeek.swift 0% 0% 0%
Core/Core/Planner/CalendarMain/View/Calendar/CalendarCardInteractionState.swift 0% 0% 0%
Core/Core/Courses/CourseProgression/GetCoursesProgressionRequest.swift 0% -- --
Core/Core/Planner/CalendarMain/Model/PlannablesInteractor.swift 0% 0% 0%
Core/Core/Planner/CalendarMain/View/Calendar/ViewPreferences.swift 0% 0% 0%
Core/Core/Planner/CalendarMain/Model/CalendarDay.swift 0% 0% 0%
Core/Core/Planner/CalendarMain/Model/CalendarMonth.swift 0% 0% 0%
Core/Core/Planner/CalendarMain/View/Calendar/CalendarUtils.swift 0% 0% 0%

Generated by 🚫 dangerJS against f165134

Copy link
Contributor

@szabinst szabinst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congrats on your first Horizon PR!

Functionality wise, it works well! I had a some remark about our coding conventions, combine usage.

Some general observations:

  • In Horizon (as opposed to Canvas) let's follow the View, Domain, Data folder structure for features.
  • When declaring properties, we usually keep them "close" without new lines. We do separate dependencies, private properties and such by marking them with a comment but each section of properties are listed without new lines.
  • Not set in stone but if a function signature is getting long (e.g 3 ore more parameters) we divide it by new lines.
  • When adding view modifiers, reactive operators we add them on new lines.
  • I added a few comments about new lines, but not everywhere.

Copy link
Contributor

@Ahmed-Naguib93 Ahmed-Naguib93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

congratulation for your first PR,
I set some comments

Ahmed-Naguib93
Ahmed-Naguib93 previously approved these changes Dec 4, 2024
@Ahmed-Naguib93
Copy link
Contributor

I'm sorry approved by mistake

Copy link
Contributor

@szabinst szabinst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes!

Last round of suggestions below.

Comment on lines +30 to +34
.frame(maxWidth: .infinity, alignment: .leading)
.padding(24)
.background(Color.white)
.cornerRadius(16)
.shadow(color: Color.black.opacity(0.2), radius: 8, x: 1, y: 2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing indentation.

Comment on lines +43 to +44
.padding(.horizontal, 24)
.padding(.bottom, 24)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing indentation.


init(
title: String,
router: Router,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of passing the whole router we could reduce the coupling by passing a closure e.g onBackButtonTap or didTap and then NotebookCourseViewModel and NotebookViewModel could handle the back logic.

Comment on lines +29 to +31
let notebookNoteLabel = courseNote.labels.map({ label in
NotebookNoteLabel.allCases.first { $0.rawValue.lowercased() == label.lowercased() }
}).filter({$0 != nil}).map({$0!}).first
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let notebookNoteLabel = courseNote.labels.map({ label in
NotebookNoteLabel.allCases.first { $0.rawValue.lowercased() == label.lowercased() }
}).filter({$0 != nil}).map({$0!}).first
let notebookNoteLabel = courseNote.labels
.map { label in
NotebookNoteLabel.allCases.first {
$0.rawValue.lowercased() == label.lowercased()
}
}
.filter {$0 != nil}
.map {$0!}
.first

private let courseId: String
private let formatter = DateFormatter()
private let getCourseNotesInteractor: GetCourseNotesInteractor
private var cancellables: Set<AnyCancellable> = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the name subscriptions as that's the project wide standard for storing AnyCancellables.

func get() -> AnyPublisher<[NotebookCourse], Error> {
courseNotesRepository
.get()
.map({ notes in notes.map({ NotebookCourse(from: $0) }) })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map({ notes in notes.map({ NotebookCourse(from: $0) }) })
.map { notes in notes.map({ NotebookCourse(from: $0) }) }

Comment on lines +58 to +62
return courses.filter({ course in
term.isEmpty ||
course.course.lowercased().contains(term.lowercased()) ||
course.institution.lowercased().contains(term.lowercased())
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return courses.filter({ course in
term.isEmpty ||
course.course.lowercased().contains(term.lowercased()) ||
course.institution.lowercased().contains(term.lowercased())
})
return courses.filter { course in
term.isEmpty ||
course.course.lowercased().contains(term.lowercased()) ||
course.institution.lowercased().contains(term.lowercased())
}

Comment on lines +37 to +38
private let getCoursesInteractor: GetCoursesInteractor
private var cancellables: Set<AnyCancellable> = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please group the router and the interactor together as they are outside dependencies and use subscriptions instead of cancellables.

Comment on lines +46 to +50
getCoursesInteractor.get().sink { _ in } receiveValue: { [weak self] courses in
self?.listItems = courses.map {
NotebookListItem(id: $0.id, course: $0.course, institution: $0.institution)
}
}.store(in: &cancellables)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
getCoursesInteractor.get().sink { _ in } receiveValue: { [weak self] courses in
self?.listItems = courses.map {
NotebookListItem(id: $0.id, course: $0.course, institution: $0.institution)
}
}.store(in: &cancellables)
getCoursesInteractor.get()
.flatMap {
$0.publisher
.map { course in
NotebookListItem(
id: course.id,
course: course.course,
institution: course.institution
)
}
.collect()
}
.replaceError(with: [])
.sink { [weak self] in
self?.listItems = $0
}
.store(in: &cancellables)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants