-
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
Changes from all commits
b314cc5
4ad04ca
9fffdd0
2e8bc9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -8,6 +8,7 @@ | |||||
import org.jdbi.v3.sqlobject.statement.SqlQuery; | ||||||
import org.jdbi.v3.sqlobject.statement.SqlUpdate; | ||||||
import telraam.database.models.Lap; | ||||||
import telraam.database.models.LapCount; | ||||||
import telraam.database.models.TeamLapCount; | ||||||
|
||||||
import java.sql.Timestamp; | ||||||
|
@@ -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") | ||||||
@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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Valid remark, I assumed data to always be there. |
||||||
@RegisterBeanMapper(LapCount.class) | ||||||
LapCount getAllForTeamBeforeTime(@Bind("lapSourceId") Integer lapSourceId, @Bind("teamId") Integer teamId, @Bind("timestamp") Timestamp timestamp); | ||||||
|
||||||
@SqlUpdate("INSERT INTO lap (team_id, lap_source_id, timestamp) " + | ||||||
"VALUES (:teamId, :lapSourceId, :timestamp)") | ||||||
@GetGeneratedKeys({"id"}) | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package telraam.database.models; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter @Setter @NoArgsConstructor | ||
public class LapCount { | ||
private int teamId; | ||
private int count; | ||
} |
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.