Let's imagine you create a Jhipster racing app where we have a Race class (id, raceName, date, List -Participant-, averageTime) which is made of Participant objects (which have an id and a racing time in seconds for each race). You would like to calculate the average time of the racing class as the times are released (as they cross the finish line) and everytime a race is consulted. For that, where would you put the method for calculating such an average?
I see 3 options:
- In the view of your angular class when you show your Race component you can bring data and calculate it each time it is shown.
- Somewhere in the Race Service Implementation.
- In the domain model with a @Transient when the Race object is instanciated
Please, if you see another options or a best practice let me know. Thanks
entity Race { raceName String, time Instant, averageTime Double }
entity Participant { racingTime Integer }
relationship OneToMany { Race{participant(id)} to Participant{race(id)} }
// SET PAGINATION OPTIONS: paginate all with pagination // paginate ChatMessage with infinite-scroll // paginate all with infinite-scroll
// SET SERVICE OPTIONS: service all with serviceImpl //service all with serviceClass
// DTO: dto all with mapstruct
// FILTERING: filter *