-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat(lapCountResource): add lap count per source & team #131
Conversation
End date should be the date of the postgres DB so in our normal settingg, the local time (UTC + 2)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 I don't know how nice the timestamp will be to use, guess we will find out :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I only just now noticed the queries can be simplified, this does the same right?
@@ -29,6 +30,14 @@ public interface LapDAO extends DAO<Lap> { | |||
@RegisterBeanMapper(Lap.class) | |||
List<Lap> getAllBySourceSorted(@Bind("lapSourceId") Integer lapSourceId); | |||
|
|||
@SqlQuery("SELECT t.id as team_id, (SELECT COUNT(*) FROM lap WHERE lap_source_id = :lapSourceId AND timestamp <= :timestamp and team_id = t.id) as count FROM team t") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SqlQuery("SELECT t.id as team_id, (SELECT COUNT(*) FROM lap WHERE lap_source_id = :lapSourceId AND timestamp <= :timestamp and team_id = t.id) as count FROM team t") | |
@SqlQuery("SELECT team_id, COUNT(*) FROM lap WHERE lap_source_id = :lapSourceId AND timestamp <= :timestamp GROUP BY team_id") |
@RegisterBeanMapper(LapCount.class) | ||
List<LapCount> getAllBeforeTime(@Bind("lapSourceId") Integer lapSourceId, @Bind("timestamp") Timestamp timestamp); | ||
|
||
@SqlQuery("SELECT t.id as team_id, (SELECT COUNT(*) FROM lap WHERE lap_source_id = :lapSourceId AND timestamp <= :timestamp and team_id = t.id) as count FROM team t where id = :teamId") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SqlQuery("SELECT t.id as team_id, (SELECT COUNT(*) FROM lap WHERE lap_source_id = :lapSourceId AND timestamp <= :timestamp and team_id = t.id) as count FROM team t where id = :teamId") | |
@SqlQuery("SELECT team_id, COUNT(*) FROM lap WHERE lap_source_id = :lapSourceId AND timestamp <= :timestamp and team_id = :teamId GROUP BY team_id") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with GROUP BY is that it doesn't return anything if a team has zero laps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid remark, I assumed data to always be there.
End date should be the date of the postgres DB so in our normal settingg, the local time (UTC + 2)
closes #110