aboutsummaryrefslogtreecommitdiff
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
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.
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/Daos.java15
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/Util.java4
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/core/db/BuildDao.java16
-rwxr-xr-x[-rw-r--r--]src/main/java/io/trygvis/esper/testing/gitorious/GitoriousProjectDiscovery.java4
-rwxr-xr-x[-rw-r--r--]src/main/java/io/trygvis/esper/testing/gitorious/GitoriousRepositoryDao.java27
-rwxr-xr-xsrc/main/resources/webapp/apps/buildApp/build.html2
-rwxr-xr-xsrc/main/resources/webapp/apps/frontPageApp/badge.html15
-rwxr-xr-xsrc/main/resources/webapp/apps/frontPageApp/build.html2
-rwxr-xr-xsrc/main/resources/webapp/apps/frontPageApp/buildList.html2
-rwxr-xr-xsrc/main/resources/webapp/apps/frontPageApp/frontPageApp.js8
-rwxr-xr-xsrc/main/resources/webapp/apps/frontPageApp/person.html6
-rwxr-xr-xsrc/main/resources/webapp/apps/jenkinsApp/build.html2
-rwxr-xr-xsrc/main/resources/webapp/apps/jenkinsApp/job.html2
13 files changed, 51 insertions, 54 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/Daos.java b/src/main/java/io/trygvis/esper/testing/Daos.java
index 1a7cb0b..0242a3a 100755
--- a/src/main/java/io/trygvis/esper/testing/Daos.java
+++ b/src/main/java/io/trygvis/esper/testing/Daos.java
@@ -9,21 +9,6 @@ import java.sql.*;
public class Daos implements Closeable {
- public enum OrderDirection {
- ASC, DESC, NONE;
-
- public String toSql(String expression) {
- switch (this) {
- case ASC:
- return expression + "expression";
- case DESC:
- return expression + "expression DESC";
- default:
- return "1";
- }
- }
- }
-
private final Connection connection;
public final FileDao fileDao;
public final GitoriousEventDao gitoriousEventDao;
diff --git a/src/main/java/io/trygvis/esper/testing/Util.java b/src/main/java/io/trygvis/esper/testing/Util.java
index 68660c4..849a6f9 100755
--- a/src/main/java/io/trygvis/esper/testing/Util.java
+++ b/src/main/java/io/trygvis/esper/testing/Util.java
@@ -77,6 +77,10 @@ public class Util {
// SQL
// -----------------------------------------------------------------------
+ public static String orderBy(String[] inputs, String... allowed) {
+ return orderBy(Arrays.asList(inputs), allowed);
+ }
+
public static String orderBy(Iterable<String> inputs, String... allowed) {
StringBuilder buffer = new StringBuilder();
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));
diff --git a/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousProjectDiscovery.java b/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousProjectDiscovery.java
index 67b6d17..d60956d 100644..100755
--- a/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousProjectDiscovery.java
+++ b/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousProjectDiscovery.java
@@ -38,7 +38,7 @@ public class GitoriousProjectDiscovery {
Set<GitoriousRepositoryDto> repositories = Collections.emptySet();
try (Connection c = boneCp.getConnection()) {
- repositories = new HashSet<>(new Daos(c).gitoriousRepositoryDao.select(Daos.OrderDirection.ASC));
+ repositories = new HashSet<>(new Daos(c).gitoriousRepositoryDao.select(true));
} catch (SQLException e) {
// ignore
}
@@ -53,7 +53,7 @@ public class GitoriousProjectDiscovery {
public void act(Connection c) throws Exception {
try (Daos daos = new Daos(c)) {
discoverProjects(daos);
- repositoryManager.update(daos.gitoriousRepositoryDao.select(Daos.OrderDirection.NONE));
+ repositoryManager.update(daos.gitoriousRepositoryDao.select(null));
daos.commit();
}
}
diff --git a/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousRepositoryDao.java b/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousRepositoryDao.java
index 903d74c..27e66fe 100644..100755
--- a/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousRepositoryDao.java
+++ b/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousRepositoryDao.java
@@ -2,8 +2,7 @@ package io.trygvis.esper.testing.gitorious;
import fj.data.*;
import io.trygvis.esper.testing.*;
-import static io.trygvis.esper.testing.Util.dateToTimestamp;
-import static io.trygvis.esper.testing.Util.timestampToDate;
+import io.trygvis.esper.testing.util.sql.*;
import java.net.*;
import java.sql.*;
@@ -11,6 +10,8 @@ import java.util.*;
import java.util.Date;
import java.util.List;
+import static io.trygvis.esper.testing.Util.*;
+
public class GitoriousRepositoryDao {
private final Connection c;
@@ -38,7 +39,7 @@ public class GitoriousRepositoryDao {
}
public int countRepositories(String projectSlug, String name) throws SQLException {
- try (PreparedStatement s = c.prepareStatement("SELECT count(*) FROM gitorious_repository WHERE project_slug=? and name=?")) {
+ try (PreparedStatement s = c.prepareStatement("SELECT count(*) FROM gitorious_repository WHERE project_slug=? AND name=?")) {
s.setString(1, projectSlug);
s.setString(2, name);
try (ResultSet rs = s.executeQuery()) {
@@ -55,21 +56,15 @@ public class GitoriousRepositoryDao {
}
}
- public List<GitoriousRepositoryDto> select(Daos.OrderDirection order) throws SQLException {
- String orderBy;
-
- switch (order) {
- case ASC:
- orderBy = "ORDER BY project_slug, name";
- break;
- case DESC:
- orderBy = "ORDER BY project_slug DESC, name DESC";
- break;
- default:
- orderBy = "";
+ public List<GitoriousRepositoryDto> select(Boolean asc) throws SQLException {
+ String sql = "SELECT " + ALL_FIELDS + " FROM gitorious_repository ";
+
+ if(asc != null) {
+ String[] orderBy = asc ? new String[]{"project_slug", "name"} : new String[]{"project_slug-", "name-"};
+ sql += orderBy(orderBy, "project_slug", "name");
}
- try (PreparedStatement s = c.prepareStatement("SELECT " + ALL_FIELDS + " FROM gitorious_repository " + orderBy)) {
+ try (PreparedStatement s = c.prepareStatement(sql)) {
return executeQuery(s);
}
}
diff --git a/src/main/resources/webapp/apps/buildApp/build.html b/src/main/resources/webapp/apps/buildApp/build.html
index 2a24b16..fec38d2 100755
--- a/src/main/resources/webapp/apps/buildApp/build.html
+++ b/src/main/resources/webapp/apps/buildApp/build.html
@@ -9,7 +9,7 @@
<table>
<tr>
<th>Date</th>
- <td>{{build.build.createdDate | date:'medium'}}</td>
+ <td>{{build.build.timestamp | date:'medium'}}</td>
</tr>
<tr>
<th>Status</th>
diff --git a/src/main/resources/webapp/apps/frontPageApp/badge.html b/src/main/resources/webapp/apps/frontPageApp/badge.html
index 48d15ce..b501f15 100755
--- a/src/main/resources/webapp/apps/frontPageApp/badge.html
+++ b/src/main/resources/webapp/apps/frontPageApp/badge.html
@@ -15,11 +15,16 @@
<p>
The badge was awarded for having {{badge.personalBadge.builds.length}} successful builds in a row:
</p>
- <ul class="unstyled">
- <li ng-repeat="b in badge.personalBadge.builds">
- <a class="btn" href="#/build/{{b}}">{{$index + 1}} <i class="icon-chevron-right"></i></a>
- </li>
- </ul>
+ <table class="table table-striped">
+ <tr ng-repeat="b in badge.personalBadge.builds">
+ <td>
+ {{b.timestamp | date:'medium'}}
+ </td>
+ <td>
+ <a class="btn" href="#/build/{{b}}">{{$index + 1}} <i class="icon-chevron-right"></i></a>
+ </td>
+ </tr>
+ </table>
</div>
</div>
diff --git a/src/main/resources/webapp/apps/frontPageApp/build.html b/src/main/resources/webapp/apps/frontPageApp/build.html
index cbf8f8e..0972758 100755
--- a/src/main/resources/webapp/apps/frontPageApp/build.html
+++ b/src/main/resources/webapp/apps/frontPageApp/build.html
@@ -16,7 +16,7 @@
</tr>
<tr>
<th>Duration</th>
- <td>{{build.build.createdDate | date:'medium'}}</td>
+ <td>{{build.build.timestamp | date:'medium'}}</td>
</tr>
</tbody>
</table>
diff --git a/src/main/resources/webapp/apps/frontPageApp/buildList.html b/src/main/resources/webapp/apps/frontPageApp/buildList.html
index ddbffe2..d069736 100755
--- a/src/main/resources/webapp/apps/frontPageApp/buildList.html
+++ b/src/main/resources/webapp/apps/frontPageApp/buildList.html
@@ -28,7 +28,7 @@
<tr ng-repeat="build in group" class="{{{true: 'success', false: 'error'}[build.build.success]}}">
<td>
<h4>
- {{build.build.createdDate | date:'shortTime'}}:
+ {{build.build.timestamp | date:'shortTime'}}:
{{{true: 'SUCCESS', false: 'FAILURE'}[build.build.success]}}
</h4>
diff --git a/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js b/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js
index c376f83..5623c18 100755
--- a/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js
+++ b/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js
@@ -88,11 +88,11 @@ function PersonCtrl($scope, $routeParams, Person, Build, JenkinsUser, PagingTabl
$scope.mode = 'overview';
var watcher = function () {
- $scope.buildGroups = groupByDay($scope.builds.rows, function(build) { return build.createdDate});
+ $scope.buildGroups = groupByDay($scope.builds.rows, function(build) { return build.timestamp});
console.log("$scope.buildGroups", $scope.buildGroups);
};
$scope.buildGroups = [];
- $scope.builds = PagingTableService.create($scope, PagingTableService.defaultCallback(Build, {person: personUuid}),
+ $scope.builds = PagingTableService.create($scope, PagingTableService.defaultCallback(Build, {person: personUuid, orderBy: "timestamp-"}),
{count: 50, watcher: watcher});
$scope.setMode = function(mode) {
@@ -118,14 +118,14 @@ function PersonCtrl($scope, $routeParams, Person, Build, JenkinsUser, PagingTabl
})});
});
- Build.query({person: personUuid}, function (builds) {
+ Build.query({person: personUuid, orderBy: "timestamp-"}, function (builds) {
$scope.recentBuilds = builds;
});
}
function BuildListCtrl($scope, Build, PagingTableService) {
var watcher = function () {
- $scope.buildGroups = groupByDay($scope.builds.rows, function(build) { return build.build.createdDate});
+ $scope.buildGroups = groupByDay($scope.builds.rows, function(build) { return build.build.timestamp});
};
$scope.buildGroups = [];
diff --git a/src/main/resources/webapp/apps/frontPageApp/person.html b/src/main/resources/webapp/apps/frontPageApp/person.html
index f88a7d0..11cfd0b 100755
--- a/src/main/resources/webapp/apps/frontPageApp/person.html
+++ b/src/main/resources/webapp/apps/frontPageApp/person.html
@@ -48,7 +48,7 @@
<h3>Recent builds</h3>
<table class="table">
<tr ng-repeat="build in recentBuilds" class="{{{true: 'success', false: 'error'}[build.success]}}">
- <td>{{build.createdDate | date:'medium'}}</td>
+ <td>{{build.timestamp | date:'medium'}}</td>
<td>{{{true: 'Success', false: 'Failure'}[build.success]}}</td>
<td><a href="#/build/{{build.uuid}}">Details</a></td>
</tr>
@@ -70,7 +70,7 @@
<table class="table">
<tr ng-repeat="build in group" class="{{{true: 'success', false: 'error'}[build.success]}}">
<td>
- {{build.createdDate | date:'shortTime'}}:
+ {{build.timestamp | date:'shortTime'}}:
{{{true: 'SUCCESS', false: 'FAILURE'}[build.success]}}
<a class="btn pull-right" href="#/build/{{build.uuid}}"><i class="icon-chevron-right"></i></a>
@@ -100,7 +100,7 @@
</thead>
<tbody>
<tr ng-repeat="build in builds.rows" class="{{{true: 'success', false: 'error'}[build.success]}}">
- <td>{{build.createdDate | date:'medium'}}</td>
+ <td>{{build.timestamp | date:'medium'}}</td>
<td>
<a class="btn btn-small" href="#/build/{{build.uuid}}"><i class="icon-chevron-right"></i></a>
</td>
diff --git a/src/main/resources/webapp/apps/jenkinsApp/build.html b/src/main/resources/webapp/apps/jenkinsApp/build.html
index db07f44..7239c90 100755
--- a/src/main/resources/webapp/apps/jenkinsApp/build.html
+++ b/src/main/resources/webapp/apps/jenkinsApp/build.html
@@ -18,7 +18,7 @@
<tbody>
<tr>
<th>Timestamp</th>
- <td>{{details.build.createdDate | date:'medium'}}</td>
+ <td>{{details.build.timestamp | date:'medium'}}</td>
</tr>
<tr>
<th>Number</th>
diff --git a/src/main/resources/webapp/apps/jenkinsApp/job.html b/src/main/resources/webapp/apps/jenkinsApp/job.html
index e0c1a10..8942ab7 100755
--- a/src/main/resources/webapp/apps/jenkinsApp/job.html
+++ b/src/main/resources/webapp/apps/jenkinsApp/job.html
@@ -38,7 +38,7 @@
</thead>
<tbody>
<tr ng-repeat="build in builds.rows" class="{{{true: 'success', false: 'error'}[build.success]}}">
- <td>{{build.createdDate | date:'medium'}}</td>
+ <td>{{build.timestamp | date:'medium'}}</td>
<td>{{build.result}}</td>
<td><a class="btn" ng-click="showBuild(build.uuid)"><i class="icon-chevron-right"></i></a></td>
</tr>