getAllEditionsActiveDuringPeriod returns incorrect list of editions
Summary
The endpoint for obtaining course editions which are active during a given period of time does not return the expected list of courses.
Steps to Reproduce
- Use EditionControllerAPI#getAllEditionsActiveDuringPeriod to request a list of course editions active during a given period of time.
- Receive an incomplete list of course editions.
Possible Fix
The logic for determining which courses are active contains two contradictions:
Relevant code from EditionRepository
:
default List<Edition> findAllActiveDuring(Period period) {
return findAll((q.startDate.before(period.getStart()).and(q.endDate.after(period.getStart())))
.or(q.startDate.after(period.getStart()).and(q.startDate.before(period.getStart())))
.or(q.startDate.after(period.getEnd()).and(q.startDate.before(period.getEnd()))));
}
This could be fixed and simplified as follows:
default List<Edition> findAllActiveDuring(Period period) {
return findAll((q.startDate.after(period.getStart()).and(q.startDate.before(period.getEnd())))
.or(q.endDate.after(period.getStart()).and(q.endDate.before(period.getEnd()))));
}