From eb6cbd28992cec9025a8e95f8f03ae3839699e0b Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sat, 19 Jan 2013 09:40:14 +0100 Subject: 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. --- .../java/io/trygvis/esper/testing/core/db/BuildDao.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/main/java/io/trygvis/esper/testing/core/db/BuildDao.java') 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 build = new SqlF() { public BuildDto apply(ResultSet rs) throws SQLException { @@ -91,7 +91,11 @@ public class BuildDao { } public List 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 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)); -- cgit v1.2.3