The code in cmd/import_student.go should only contain minimal control logic for input / output. Business logic needs to be moved into relevant repositories in the repository/ directory. This improves code flexibility and maintainability.
Success criteria
[ ] Write a more specific iterator in the LDAP repository, for instance FetchStudents(func(p *models.Person))
[ ] Move the mapping logic the callback to the database repository as a separate method, for instance UpsertStudent(p *models.Person).
Implementation suggestion
The scope of this issue is limited to moving existing code in cmd/import_student.go to repositories from where it is called. Not refactoring the code itself.
A great example of how the code should look is deliver/cli/files_cmd.go. The command just instantiates the repositories, calls an iterator and then methods on repositories.
Story
The code in
cmd/import_student.go
should only contain minimal control logic for input / output. Business logic needs to be moved into relevant repositories in therepository/
directory. This improves code flexibility and maintainability.Success criteria
FetchStudents(func(p *models.Person))
UpsertStudent(p *models.Person)
.Implementation suggestion
The scope of this issue is limited to moving existing code in
cmd/import_student.go
to repositories from where it is called. Not refactoring the code itself.A great example of how the code should look is deliver/cli/files_cmd.go. The command just instantiates the repositories, calls an iterator and then methods on repositories.
Automatic testing scenario
n/a
Additional information
n/a
Related issues
31