Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Hide lanes that both 1) track a branch with no new commits in the las…

…t 30 days and 2) have no pending work.
  • Loading branch information...
commit 7f3775a83e0a37fa68b6b1410c2416244b42b689 1 parent 51ebb12
@rolfbjarne rolfbjarne authored
View
1  MonkeyWrench.Web.UI/index.aspx.cs
@@ -93,6 +93,7 @@ protected override void OnLoad (EventArgs e)
return;
}
lblMessage.Text = data.Exception.Message;
+ MonkeyWrench.Logger.Log ("index.aspx exception: {0}", data.Exception.AsString);
return;
}
View
77 MonkeyWrench.Web.WebService/WebServices.asmx.cs
@@ -1017,10 +1017,15 @@ public FrontPageResponse GetFrontPageData2 (WebServiceLogin login, int limit, st
{
return GetFrontPageData3 (login, limit, 0, lanes, lane_ids);
}
+ [WebMethod]
+ public FrontPageResponse GetFrontPageData3 (WebServiceLogin login, int page_size, int page, string [] lanes, int [] lane_ids)
+ {
+ return GetFrontPageData4 (login, page_size, page, lanes, lane_ids, 30);
+ }
// for some unknown reason we receive all elements in int? [] arrays with HasValue = false:
[WebMethod]
- public FrontPageResponse GetFrontPageData3 (WebServiceLogin login, int page_size, int page, string [] lanes, int [] lane_ids)
+ public FrontPageResponse GetFrontPageData4 (WebServiceLogin login, int page_size, int page, string [] lanes, int [] lane_ids, int latest_days)
{
FrontPageResponse response = new FrontPageResponse ();
List<DBLane> Lanes = new List<DBLane> ();
@@ -1029,24 +1034,63 @@ public FrontPageResponse GetFrontPageData3 (WebServiceLogin login, int page_size
page_size = Math.Min (page_size, 500);
+ string single_lane = string.Empty;
+ if ((lanes != null && lanes.Length == 1))
+ single_lane = lanes [0];
+
try {
using (DB db = new DB ()) {
Authenticate (db, login, response, true);
using (IDbCommand cmd = db.CreateCommand ()) {
- cmd.CommandText = "SELECT * FROM Lane WHERE enabled = TRUE;";
- using (IDataReader reader = cmd.ExecuteReader ()) {
- while (reader.Read ())
- Lanes.Add (new DBLane (reader));
+ var latest_only = latest_days != 0;
+ var last_month = string.Empty;
+
+ if (!string.IsNullOrEmpty (single_lane)) {
+ // this will ignore the @afterdate condition below if the selected lane is not a parent of other lanes
+ last_month = " AND (NOT EXISTS (SELECT id FROM Lane WHERE parent_lane_id = (SELECT id FROM Lane WHERE lane = @single_lane)) OR \n";
+ DB.CreateParameter (cmd, "single_lane", single_lane);
+ } else {
+ last_month = " AND (";
}
- }
- using (IDbCommand cmd = db.CreateCommand ()) {
- cmd.CommandText = DBHost.TableName;
- cmd.CommandType = CommandType.TableDirect;
+ last_month += @"
+ (
+ EXISTS (SELECT id FROM Revision WHERE date > @afterdate AND lane_id = Lane.id)
+ OR
+ EXISTS (SELECT id FROM RevisionWork WHERE lane_id = Lane.id AND ((completed = TRUE AND endtime > @afterdate) OR (state <> 11 AND completed = FALSE)))
+ OR
+ NOT EXISTS (SELECT id FROM Revision WHERE lane_id = Lane.id)
+ OR
+ EXISTS (SELECT id FROM Lane AS ParentLane WHERE ParentLane.parent_lane_id = Lane.id)
+ ))";
+ /*
+ */
+
+ cmd.CommandText = "SELECT * FROM Lane WHERE enabled = TRUE";
+ if (latest_only)
+ cmd.CommandText += last_month;
+ cmd.CommandText += ";\n";
+ cmd.CommandText += "SELECT * FROM Host;\n";
+ cmd.CommandText += @"
+SELECT HostLane.*
+FROM HostLane
+INNER JOIN Lane ON Lane.id = HostLane.lane_id
+WHERE hidden = false AND Lane.enabled = TRUE";
+ if (latest_only)
+ cmd.CommandText += last_month;
+ cmd.CommandText += ";\n";
+ if (latest_only)
+ DB.CreateParameter (cmd, "afterdate", DateTime.Now.AddDays (-latest_days));
using (IDataReader reader = cmd.ExecuteReader ()) {
while (reader.Read ())
+ Lanes.Add (new DBLane (reader));
+ reader.NextResult ();
+ while (reader.Read ())
Hosts.Add (new DBHost (reader));
+ reader.NextResult ();
+ while (reader.Read ())
+ HostLanes.Add (new DBHostLane (reader));
}
}
@@ -1075,19 +1119,6 @@ public FrontPageResponse GetFrontPageData3 (WebServiceLogin login, int page_size
if (response.SelectedLanes.Count == 1)
response.Lane = response.SelectedLanes [0];
- using (IDbCommand cmd = db.CreateCommand ()) {
- cmd.CommandText = @"
-SELECT HostLane.*
-FROM HostLane
-INNER JOIN Lane ON Lane.id = HostLane.lane_id
-WHERE hidden = false AND Lane.enabled = TRUE";
-
- using (IDataReader reader = cmd.ExecuteReader ()) {
- while (reader.Read ())
- HostLanes.Add (new DBHostLane (reader));
- }
- }
-
response.RevisionWorkViews = new List<List<DBRevisionWorkView2>> (HostLanes.Count);
response.RevisionWorkHostLaneRelation = new List<int> (HostLanes.Count);
@@ -1095,6 +1126,8 @@ FROM HostLane
using (IDbCommand cmd = db.CreateCommand ()) {
var revisionworklists = new Queue<List<DBRevisionWorkView2>> ();
+ // FIXME: use this instead: https://gist.github.com/rolfbjarne/cf73bf22209c8a8ef844
+
for (int i = 0; i < HostLanes.Count; i++) {
DBHostLane hl = HostLanes [i];
var RevisionWork = new List<DBRevisionWorkView2> ();
Please sign in to comment.
Something went wrong with that request. Please try again.