aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/trygvis/esper/testing/core/db/BuildDao.java
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-01-19 09:40:14 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2013-01-19 09:40:14 +0100
commiteb6cbd28992cec9025a8e95f8f03ae3839699e0b (patch)
treed3c1f1416da2ae36894d3087a75f3c1d7f280fad /src/main/java/io/trygvis/esper/testing/core/db/BuildDao.java
parent17be3886fbee46c34f1ea78cd32d5726e538e641 (diff)
downloadesper-testing-eb6cbd28992cec9025a8e95f8f03ae3839699e0b.tar.gz
esper-testing-eb6cbd28992cec9025a8e95f8f03ae3839699e0b.tar.bz2
esper-testing-eb6cbd28992cec9025a8e95f8f03ae3839699e0b.tar.xz
esper-testing-eb6cbd28992cec9025a8e95f8f03ae3839699e0b.zip
o Reverting the timestamp => createdDate change, it was wrong. Adding ability to sort on timestamp.
Created date is when we discovered the build, the timestamp is when Jenkins did the build.
Diffstat (limited to 'src/main/java/io/trygvis/esper/testing/core/db/BuildDao.java')
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/core/db/BuildDao.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/core/db/BuildDao.java b/src/main/java/io/trygvis/esper/testing/core/db/BuildDao.java
index 32afe42..c6a46c6 100755
--- a/src/main/java/io/trygvis/esper/testing/core/db/BuildDao.java
+++ b/src/main/java/io/trygvis/esper/testing/core/db/BuildDao.java
@@ -7,7 +7,7 @@ import org.joda.time.*;
import java.sql.*;
import java.util.*;
-import static io.trygvis.esper.testing.Util.toList;
+import static io.trygvis.esper.testing.Util.*;
import static io.trygvis.esper.testing.util.sql.ResultSetF.*;
import static io.trygvis.esper.testing.util.sql.SqlOption.fromRs;
import static java.lang.System.*;
@@ -15,7 +15,7 @@ import static java.lang.System.*;
public class BuildDao {
private final Connection c;
- public static final String BUILD = "uuid, created_date, timestamp, success, reference_type, reference_uuid";
+ public static final String BUILD = "UUID, created_date, TIMESTAMP, success, reference_type, reference_uuid";
public static final SqlF<ResultSet, BuildDto> build = new SqlF<ResultSet, BuildDto>() {
public BuildDto apply(ResultSet rs) throws SQLException {
@@ -91,7 +91,11 @@ public class BuildDao {
}
public List<BuildDto> selectBuildsByPerson(Uuid person, PageRequest page) throws SQLException {
- try (PreparedStatement s = c.prepareStatement("SELECT " + BUILD + " FROM build b, build_participant bp WHERE bp.person=? AND b.uuid = bp.build ORDER BY created_date DESC LIMIT ? OFFSET ?")) {
+ String sql = "SELECT " + BUILD + " FROM build b, build_participant bp WHERE bp.person=? AND b.uuid = bp.build";
+ sql += orderBy(page.orderBy, "created_date", "timestamp");
+ sql += " LIMIT ? OFFSET ?";
+
+ try (PreparedStatement s = c.prepareStatement(sql)) {
int i = 1;
s.setString(i++, person.toUuidString());
s.setInt(i++, page.count.orSome(10));
@@ -101,7 +105,11 @@ public class BuildDao {
}
public List<BuildDto> selectBuilds(PageRequest page) throws SQLException {
- try (PreparedStatement s = c.prepareStatement("SELECT " + BUILD + " FROM build ORDER BY created_date DESC LIMIT ? OFFSET ?")) {
+ String sql = "SELECT " + BUILD + " FROM build";
+ sql += orderBy(page.orderBy, "created_date", "timestamp");
+ sql += " LIMIT ? OFFSET ?";
+
+ try (PreparedStatement s = c.prepareStatement(sql)) {
int i = 1;
s.setInt(i++, page.count.orSome(10));
s.setInt(i, page.startIndex.orSome(0));