I have a model called Client that has these info :
private Long int;
@OneToMany(mappedBy = "client", cascade = CascadeType.ALL)
private List<Results> results;
and The model Results has these info :
@ManyToOne
@JoinColumn(name='client_id')
private Client client;
@OneToOne
private Scores score;
private Date submittedDate;
What I'm trying to achieve is this :
For every user get the score of their first result and the score of their last result, find the difference. And then average out everyone's differences. How do I write this function that calculates it?
The Client returns a list of all results, and then for difference : results[last] - results[0] and then a loop :
for (int i=0; i <= client.count(); i++)
difference = results[last] - results[0];
sum += difference;
average = sum/client.count();`
I just have difficulty into turning this into code that works in Spring. Do I write this in the ClientServiceImplementation and then have the queries in ClientRepository ? Any help is appreciated!!!
the Score class has :
private Long id;
private Double score;