API changes

Also update the Xbox lab
This commit is contained in:
Thomas Hounsell 2017-04-18 21:29:43 +01:00
parent f2d3810da1
commit 455f48c2ac
4 changed files with 99 additions and 7 deletions

View File

@ -0,0 +1,21 @@
using System;
namespace BuildFeed.Model.Api
{
public class ApiBuild : BuildDetails
{
public Guid Id { get; set; }
public string FullBuildString { get; set; }
public string AlternateBuildString { get; set; }
public string LabUrl { get; set; }
public bool IsLeaked => SourceType == TypeOfSource.PublicRelease || SourceType == TypeOfSource.InternalLeak || SourceType == TypeOfSource.UpdateGDR;
public DateTime Added { get; set; }
public DateTime Modified { get; set; }
}
}

View File

@ -89,6 +89,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Api\ApiBuild.cs" />
<Compile Include="Api\NewBuild.cs" />
<Compile Include="Api\SearchResult.cs" />
<Compile Include="BuildDetails.cs" />

View File

@ -25,10 +25,33 @@ public ApiController()
_bModel = new BuildRepository();
}
public async Task<Build[]> GetBuilds(int limit = 20, int skip = 0)
public async Task<ApiBuild[]> GetBuilds(int limit = 20, int skip = 0)
{
List<Build> builds = await _bModel.SelectBuildsByOrder(limit, skip);
return builds.ToArray();
return (from b in builds
select new ApiBuild
{
Id = b.Id,
MajorVersion = b.MajorVersion,
MinorVersion = b.MinorVersion,
Number = b.Number,
Revision = b.Revision,
Lab = b.Lab,
BuildTime = b.BuildTime,
SourceType = b.SourceType,
SourceDetails = b.SourceDetails,
LeakDate = b.LeakDate,
FullBuildString = b.FullBuildString,
AlternateBuildString = b.AlternateBuildString,
LabUrl = b.LabUrl,
Added = b.Added,
Modified = b.Modified
}).ToArray();
}
public async Task<FrontBuildGroup[]> GetBuildGroups(int limit = 20, int skip = 0)
@ -37,7 +60,7 @@ public async Task<FrontBuildGroup[]> GetBuildGroups(int limit = 20, int skip = 0
return bgroups.ToArray();
}
public async Task<Build[]> GetBuildsForBuildGroup(uint major, uint minor, uint number, uint? revision = null)
public async Task<ApiBuild[]> GetBuildsForBuildGroup(uint major, uint minor, uint number, uint? revision = null)
{
List<Build> builds = await _bModel.SelectGroup(new BuildGroup
{
@ -47,13 +70,60 @@ public async Task<Build[]> GetBuildsForBuildGroup(uint major, uint minor, uint n
Revision = revision
});
return builds.ToArray();
return (from b in builds
select new ApiBuild
{
Id = b.Id,
MajorVersion = b.MajorVersion,
MinorVersion = b.MinorVersion,
Number = b.Number,
Revision = b.Revision,
Lab = b.Lab,
BuildTime = b.BuildTime,
SourceType = b.SourceType,
SourceDetails = b.SourceDetails,
LeakDate = b.LeakDate,
FullBuildString = b.FullBuildString,
AlternateBuildString = b.AlternateBuildString,
LabUrl = b.LabUrl,
Added = b.Added,
Modified = b.Modified
}).ToArray();
}
public async Task<Build[]> GetBuildsByLab(string lab, int limit = 20, int skip = 0)
public async Task<ApiBuild[]> GetBuildsByLab(string lab, int limit = 20, int skip = 0)
{
List<Build> builds = await _bModel.SelectLab(lab, limit, skip);
return builds.ToArray();
return (from b in builds
select new ApiBuild
{
Id = b.Id,
MajorVersion = b.MajorVersion,
MinorVersion = b.MinorVersion,
Number = b.Number,
Revision = b.Revision,
Lab = b.Lab,
BuildTime = b.BuildTime,
SourceType = b.SourceType,
SourceDetails = b.SourceDetails,
LeakDate = b.LeakDate,
FullBuildString = b.FullBuildString,
AlternateBuildString = b.AlternateBuildString,
LabUrl = b.LabUrl,
Added = b.Added,
Modified = b.Modified
}).ToArray();
}
public async Task<IEnumerable<string>> GetWin10Labs()

View File

@ -11,7 +11,7 @@
<add key="site:OSGLab" value="rs_prerelease" />
<add key="site:InsiderLab" value="rs_prerelease" />
<add key="site:ReleaseLab" value="rs2_release;rs2_release_svc_sec;rs2_release_svc_escrow" />
<add key="site:XboxLab" value="rs2_release_xbox_1704" />
<add key="site:XboxLab" value="rs2_release_xbox_1705" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.6.2">