From 38e54126ee55a59e38eef187a5918602f1eb6bb6 Mon Sep 17 00:00:00 2001 From: Thomas Hounsell Date: Mon, 27 Oct 2014 10:14:31 +0000 Subject: [PATCH] IsLeaked Property added, GetWin10Labs API Also support multi-line source detail fields. --- BuildFeed.csproj | 1 + Controllers/apiController.cs | 5 +++++ Models/Build.cs | 33 +++++++++++++++++++++++++++++++++ Views/build/info.cshtml | 2 +- 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/BuildFeed.csproj b/BuildFeed.csproj index 7ffcdb1..394b67d 100644 --- a/BuildFeed.csproj +++ b/BuildFeed.csproj @@ -219,6 +219,7 @@ + diff --git a/Controllers/apiController.cs b/Controllers/apiController.cs index d80796d..233037a 100644 --- a/Controllers/apiController.cs +++ b/Controllers/apiController.cs @@ -14,5 +14,10 @@ public IEnumerable GetBuilds() { return Build.SelectInBuildOrder(); } + + public IEnumerable GetWin10Labs() + { + return Build.SelectBuildLabs(6, 4); + } } } diff --git a/Models/Build.cs b/Models/Build.cs index 7e0dea4..664585e 100644 --- a/Models/Build.cs +++ b/Models/Build.cs @@ -81,6 +81,22 @@ public class Build : IHasId [EnumDataType(typeof(LevelOfFlight))] public LevelOfFlight FlightLevel { get; set; } + public bool IsLeaked + { + get + { + switch(SourceType) + { + case TypeOfSource.PublicRelease: + case TypeOfSource.InternalLeak: + case TypeOfSource.UpdateGDR: + return true; + default: + return false; + } + } + } + public string FullBuildString { get @@ -186,6 +202,23 @@ public static IEnumerable SelectBuildLabs() } } + [DataObjectMethod(DataObjectMethodType.Select, false)] + public static IEnumerable SelectBuildLabs(byte major, byte minor) + { + using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database)) + { + var client = rClient.As(); + var results = client.GetAll() + .Where(b => !string.IsNullOrWhiteSpace(b.Lab)) + .Where(b => b.MajorVersion == major) + .Where(b => b.MinorVersion == minor) + .GroupBy(b => b.Lab.ToLower()) + .Select(b => b.First().Lab.ToLower()) + .OrderBy(s => s); + return results; + } + } + [DataObjectMethod(DataObjectMethodType.Insert, true)] public static void Insert(Build item) { diff --git a/Views/build/info.cshtml b/Views/build/info.cshtml index 3343e87..aa2a0ef 100644 --- a/Views/build/info.cshtml +++ b/Views/build/info.cshtml @@ -71,7 +71,7 @@
@Html.LabelFor(model => model.SourceDetails, new { @class = "control-label col-sm-2" })
-

@Html.DisplayFor(model => model.SourceDetails)

+

@Html.Raw(Html.DisplayFor(model => model.SourceDetails).ToHtmlString().Replace("\r\n", "
"))