Skip to content

Commit

Permalink
Merge pull request #34 from BertCotton/RemoveCompletedPRs
Browse files Browse the repository at this point in the history
Remove completed p rs
  • Loading branch information
BertCotton authored Aug 4, 2017
2 parents 293055a + b6a56eb commit dbf6aa8
Show file tree
Hide file tree
Showing 104 changed files with 1,063 additions and 530 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ src/*/wwwroot/lib/
src/*/wwwroot/fonts/
src/*/wwwroot/_references.js

!src/**/Models/Releases/


node_modules/
Expand Down
10 changes: 6 additions & 4 deletions TfsAdvanced.sln
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26403.0
VisualStudioVersion = 15.0.26430.15
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{28430696-29B7-46F4-9140-2EF000FB2D29}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{BB3621F3-9DFF-49AD-9482-D325EC7DD410}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
.travis.yml = .travis.yml
build.sh = build.sh
nuget.config = nuget.config
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Web", "src\TfsAdvanced\Web.csproj", "{5FFBC1A5-B8CE-44D5-99E7-64B9903E0BAD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataStore", "src\TfsAdvanced.DataStore\DataStore.csproj", "{B91AC19E-9D65-416C-8B4D-47C7D7F41C63}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataStore", "src\TfsAdvanced.DataStore\DataStore.csproj", "{B91AC19E-9D65-416C-8B4D-47C7D7F41C63}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Models", "src\TfsAdvanced.Models\Models.csproj", "{23D45B3D-C188-48F3-9078-35B61B1F293D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Models", "src\TfsAdvanced.Models\Models.csproj", "{23D45B3D-C188-48F3-9078-35B61B1F293D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Updater", "src\TfsAdvanced.Updater\Updater.csproj", "{F88AE0D1-17B4-427E-8023-42A183EB05D3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Updater", "src\TfsAdvanced.Updater\Updater.csproj", "{F88AE0D1-17B4-427E-8023-42A183EB05D3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
16 changes: 4 additions & 12 deletions src/TfsAdvanced.DataStore/Repository/BuildDefinitionRepository.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Reflection;
using System.Threading;
using Microsoft.EntityFrameworkCore;
using TfsAdvanced.Models.Builds;
using TFSAdvanced.DataStore.Repository;
using TFSAdvanced.DataStore.Repository;
using TFSAdvanced.Models.DTO;

namespace TfsAdvanced.DataStore.Repository
{
Expand All @@ -16,13 +8,13 @@ public class BuildDefinitionRepository : RepositoryBase<BuildDefinition>

public BuildDefinition GetBuildDefinition(int definitionId)
{
return base.Get(definition => definition.id == definitionId);
return base.Get(definition => definition.Id == definitionId);
}


protected override int GetId(BuildDefinition item)
{
return item.id;
return item.Id;
}
}

Expand Down
12 changes: 5 additions & 7 deletions src/TfsAdvanced.DataStore/Repository/BuildRepository.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using TfsAdvanced.Models.Builds;
using TFSAdvanced.DataStore.Repository;
using TFSAdvanced.Models.DTO;

namespace TfsAdvanced.DataStore.Repository
{
Expand All @@ -13,24 +11,24 @@ public class BuildRepository : RepositoryBase<Build>

public Build GetBuild(int buildId)
{
return base.Get(b => b.id == buildId);
return base.Get(b => b.Id == buildId);
}

public Build GetBuildBySourceVersion(string commitId)
{
return base.GetList(b => b.sourceVersion == commitId).OrderByDescending(b => b.id).FirstOrDefault();
return base.GetList(b => b.SourceCommit == commitId).OrderByDescending(b => b.Id).FirstOrDefault();
}

protected override int GetId(Build item)
{
return item.id;
return item.Id;
}

public override void Update(IEnumerable<Build> updates)
{
base.Update(updates);
DateTime yesterday = DateTime.Now.Date.AddDays(-2);
base.Cleanup(x => x.queueTime < yesterday);
base.Cleanup(x => x.QueuedDate < yesterday);
}
}

Expand Down
28 changes: 10 additions & 18 deletions src/TfsAdvanced.DataStore/Repository/JobRequestRepository.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using TfsAdvanced.Models.JobRequests;
using TFSAdvanced.DataStore.Repository;
using TFSAdvanced.Models.DTO;

namespace TfsAdvanced.DataStore.Repository
{
public class JobRequestRepository
public class JobRequestRepository : RepositoryBase<QueueJob>
{
private ConcurrentBag<JobRequest> jobRequests;

public JobRequestRepository()
{
this.jobRequests = new ConcurrentBag<JobRequest>();
}

public IList<JobRequest> GetJobRequests(DateTime? fromDate = null, DateTime? toDate = null)
public IEnumerable<QueueJob> GetJobRequests(DateTime? fromDate = null, DateTime? toDate = null)
{
if(fromDate.HasValue && toDate.HasValue)
return jobRequests.Where(x => x.queueTime >= fromDate.Value && x.queueTime <= toDate.Value).ToList();
return base.GetList(x => x.QueuedTime >= fromDate.Value && x.QueuedTime <= toDate.Value);
if (fromDate.HasValue)
return jobRequests.Where(x => x.queueTime >= fromDate.Value).ToList();
return base.GetList(x => x.QueuedTime >= fromDate.Value);
if(toDate.HasValue)
return jobRequests.Where(x => x.queueTime <= toDate.Value).ToList();
return base.GetList(x => x.QueuedTime <= toDate.Value);

return jobRequests.ToList();
return GetAll();
}

public void UpdateJobRequests(IList<JobRequest> jobRequests)
protected override int GetId(QueueJob item)
{
this.jobRequests = new ConcurrentBag<JobRequest>(jobRequests);
return item.RequestId;
}
}
}
23 changes: 0 additions & 23 deletions src/TfsAdvanced.DataStore/Repository/PolicyRepository.cs

This file was deleted.

7 changes: 2 additions & 5 deletions src/TfsAdvanced.DataStore/Repository/PoolRepository.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using TfsAdvanced.Models.Pools;
using TFSAdvanced.DataStore.Repository;
using TFSAdvanced.DataStore.Repository;
using TFSAdvanced.Models.DTO;

namespace TfsAdvanced.DataStore.Repository
{
Expand Down
28 changes: 5 additions & 23 deletions src/TfsAdvanced.DataStore/Repository/ProjectRepository.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using TfsAdvanced.Models.Projects;
using TFSAdvanced.DataStore.Repository;
using TFSAdvanced.DataStore.Repository;
using TFSAdvanced.Models.DTO;

namespace TfsAdvanced.DataStore.Repository
{
Expand All @@ -14,25 +8,13 @@ public class ProjectRepository : RepositoryBase<Project>

public Project GetProject(string projectId)
{
return base.Get(p => p.id == projectId);
return base.Get(p => p.Id == projectId);
}

protected override int GetId(Project item)
{
return item.id.GetHashCode();
}
}

class ProjectComparer : IEqualityComparer<Project>
{
public bool Equals(Project x, Project y)
{
return x.id == y.id;
}

public int GetHashCode(Project obj)
{
return obj.id.GetHashCode();
return item.Id.GetHashCode();
}
}

}
12 changes: 5 additions & 7 deletions src/TfsAdvanced.DataStore/Repository/PullRequestRepository.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Models.PullRequests;
using TfsAdvanced.Models.PullRequests;
using TFSAdvanced.DataStore.Repository;
using TFSAdvanced.Models.DTO;

namespace TfsAdvanced.DataStore.Repository
{
Expand All @@ -12,19 +10,19 @@ public class PullRequestRepository : RepositoryBase<PullRequest>

public IEnumerable<PullRequest> GetPullRequestsAfter(int id)
{
return base.GetList(x => x.pullRequestId > id);
return base.GetList(x => x.Id > id);
}

protected override int GetId(PullRequest item)
{
return item.pullRequestId;
return item.Id;
}

public override void Update(IEnumerable<PullRequest> updates)
{
base.Update(updates);
// If an update was not received, then remove it
var noUpdate = base.GetList(request => !updates.Select(x => x.pullRequestId).Contains(request.pullRequestId));
var noUpdate = base.GetList(request => !updates.Select(x => x.Id).Contains(request.Id));
base.Remove(noUpdate);

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using TFSAdvanced.Models.DTO;

namespace TFSAdvanced.DataStore.Repository
{
public class ReleaseDefinitionRepository : RepositoryBase<ReleaseDefinition>
{
protected override int GetId(ReleaseDefinition item)
{
return item.Id;
}

public ReleaseDefinition GetReleaseDefinition(int id)
{
return Get(definition => definition.Id == id);
}
}
}
2 changes: 0 additions & 2 deletions src/TfsAdvanced.DataStore/Repository/RepositoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using System.Threading;
using Microsoft.EntityFrameworkCore;

namespace TFSAdvanced.DataStore.Repository
{
Expand Down
16 changes: 9 additions & 7 deletions src/TfsAdvanced.DataStore/Repository/RepositoryRepository.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using TFSAdvanced.DataStore.Repository;
using TFSAdvanced.DataStore.Repository;

namespace TfsAdvanced.DataStore.Repository
{
public class RepositoryRepository : RepositoryBase<Models.Repositories.Repository>
public class RepositoryRepository : RepositoryBase<TFSAdvanced.Models.DTO.Repository>
{
protected override int GetId(Models.Repositories.Repository item)
protected override int GetId(TFSAdvanced.Models.DTO.Repository item)
{
return item.id.GetHashCode();
return item.Id.GetHashCode();
}

public TFSAdvanced.Models.DTO.Repository GetById(string Id)
{
return Get(x => x.Id == Id);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace TfsAdvanced.DataStore.Repository
{
public class UpdateStatusRepository
{
private ConcurrentDictionary<string, UpdateStatus> updateStatuses;
private readonly ConcurrentDictionary<string, UpdateStatus> updateStatuses;

public UpdateStatusRepository()
{
Expand Down
8 changes: 1 addition & 7 deletions src/TfsAdvanced.DataStore/TfsAdvancedDataContext.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using TfsAdvanced.Data;
using Microsoft.EntityFrameworkCore.Storage.Internal;
using Microsoft.EntityFrameworkCore;
using TfsAdvanced.Models.Infrastructure;

namespace TfsAdvanced.Data
Expand Down
29 changes: 29 additions & 0 deletions src/TfsAdvanced.Models/DTO/Build.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;

namespace TFSAdvanced.Models.DTO
{
public class Build
{
public int Id { get; set; }

public string Name { get; set; }

public string Folder { get; set; }

public string Url { get; set; }

public User Creator { get; set; }

public Repository Repository { get; set; }

public string SourceCommit { get; set; }

public BuildStatus BuildStatus { get; set; }

public DateTime QueuedDate { get; set; }

public DateTime? StartedDate { get; set; }

public DateTime? FinishedDate { get; set; }
}
}
19 changes: 19 additions & 0 deletions src/TfsAdvanced.Models/DTO/BuildDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace TFSAdvanced.Models.DTO
{
public class BuildDefinition
{
public int Id { get; set; }

public string Name { get; set; }

public string Url { get; set; }

public int QueueId { get; set; }

public Repository Repository { get; set; }

public string Folder { get; set; }

public string DefaultBranch { get; set; }
}
}
Loading

0 comments on commit dbf6aa8

Please sign in to comment.