RSS feed changes - Hashtags & Categories

This commit is contained in:
BuildFeed Bot 2018-02-06 18:37:02 +00:00
parent c2c02f1b73
commit e6f5ac6fe4
3 changed files with 105 additions and 92 deletions

View File

@ -44,6 +44,25 @@ public class Build : BuildDetails
[Display(ResourceType = typeof(VariantTerms), Name = nameof(VariantTerms.Search_Version))]
public ProjectFamily Family { get; private set; }
public string[] RssCategories
{
get
{
var categories = new List<string>
{
Family.ToString(),
"Windows"
};
if ((int)Family >= BuildRepository.CURRENT_RELEASE)
{
categories.Add("WindowsInsiders");
}
return categories.ToArray();
}
}
public string SourceDetailsFiltered
{
get

View File

@ -11,6 +11,10 @@ namespace BuildFeed.Model
{
public partial class BuildRepository
{
public const int CURRENT_LONG_TERM = (int)ProjectFamily.Redstone;
public const int CURRENT_RELEASE = (int)ProjectFamily.Feature2;
public const int CURRENT_XBOX = (int)ProjectFamily.Redstone3;
private const string BUILD_COLLECTION_NAME = "builds";
private static readonly BsonDocument sortByAddedDate = new BsonDocument(nameof(Build.Added), -1);
private static readonly BsonDocument sortByCompileDate = new BsonDocument(nameof(Build.BuildTime), -1);
@ -158,10 +162,6 @@ public async Task<List<Build>> SelectBuildsByOrder(int limit = -1, int skip = 0)
[DataObjectMethod(DataObjectMethodType.Select, false)]
public async Task<Dictionary<ProjectFamily, FrontPage>> SelectFrontPage()
{
const int currentLongTerm = (int)ProjectFamily.Redstone;
const int currentFamily = (int)ProjectFamily.Feature2;
const int currentXbox = (int)ProjectFamily.Redstone3;
var families = new Dictionary<ProjectFamily, FrontPage>();
var query = _buildCollection.Aggregate()
@ -175,14 +175,14 @@ public async Task<Dictionary<ProjectFamily, FrontPage>> SelectFrontPage()
{
nameof(Build.Family), new BsonDocument
{
{"$gte", currentFamily}
{ "$gte", CURRENT_RELEASE }
}
}
},
new BsonDocument
{
{
nameof(Build.Family), currentLongTerm
nameof(Build.Family), CURRENT_LONG_TERM
}
}
}
@ -193,9 +193,9 @@ public async Task<Dictionary<ProjectFamily, FrontPage>> SelectFrontPage()
{
"_id", new BsonDocument
{
{nameof(Build.Family), $"${nameof(Build.Family)}"},
{nameof(Build.LabUrl), $"${nameof(Build.LabUrl)}"},
{nameof(Build.SourceType), $"${nameof(Build.SourceType)}"}
{ nameof(Build.Family), $"${nameof(Build.Family)}" },
{ nameof(Build.LabUrl), $"${nameof(Build.LabUrl)}" },
{ nameof(Build.SourceType), $"${nameof(Build.SourceType)}" }
}
},
{
@ -204,13 +204,13 @@ public async Task<Dictionary<ProjectFamily, FrontPage>> SelectFrontPage()
{
"$push", new BsonDocument
{
{nameof(Build.Id), "$_id"},
{nameof(Build.MajorVersion), $"${nameof(Build.MajorVersion)}"},
{nameof(Build.MinorVersion), $"${nameof(Build.MinorVersion)}"},
{nameof(Build.Number), $"${nameof(Build.Number)}"},
{nameof(Build.Revision), $"${nameof(Build.Revision)}"},
{nameof(Build.Lab), $"${nameof(Build.Lab)}"},
{nameof(Build.BuildTime), $"${nameof(Build.BuildTime)}"}
{ nameof(Build.Id), "$_id" },
{ nameof(Build.MajorVersion), $"${nameof(Build.MajorVersion)}" },
{ nameof(Build.MinorVersion), $"${nameof(Build.MinorVersion)}" },
{ nameof(Build.Number), $"${nameof(Build.Number)}" },
{ nameof(Build.Revision), $"${nameof(Build.Revision)}" },
{ nameof(Build.Lab), $"${nameof(Build.Lab)}" },
{ nameof(Build.BuildTime), $"${nameof(Build.BuildTime)}" }
}
}
}
@ -254,27 +254,27 @@ public async Task<Dictionary<ProjectFamily, FrontPage>> SelectFrontPage()
.OrderByDescending(b => b.BuildTime)
.FirstOrDefault(),
CurrentInsider = results
.Where(g => g.Key.Family == family &&
!g.Key.LabUrl.Contains("xbox") &&
(g.Key.SourceType == TypeOfSource.PublicRelease ||
g.Key.SourceType == TypeOfSource.UpdateGDR))
.Where(g => g.Key.Family == family
&& !g.Key.LabUrl.Contains("xbox")
&& (g.Key.SourceType == TypeOfSource.PublicRelease
|| g.Key.SourceType == TypeOfSource.UpdateGDR))
.SelectMany(g => g.Items)
.OrderByDescending(b => b.BuildTime)
.FirstOrDefault(),
CurrentRelease = results
.Where(g => g.Key.Family == family &&
g.Key.LabUrl.Contains("_release") &&
!g.Key.LabUrl.Contains("xbox") &&
(g.Key.SourceType == TypeOfSource.PublicRelease ||
g.Key.SourceType == TypeOfSource.UpdateGDR))
.Where(g => g.Key.Family == family
&& g.Key.LabUrl.Contains("_release")
&& !g.Key.LabUrl.Contains("xbox")
&& (g.Key.SourceType == TypeOfSource.PublicRelease
|| g.Key.SourceType == TypeOfSource.UpdateGDR))
.SelectMany(g => g.Items)
.OrderByDescending(b => b.BuildTime)
.FirstOrDefault(),
CurrentXbox =
results.Where(g
=> (int)g.Key.Family >= currentXbox &&
g.Key.Family == family &&
g.Key.LabUrl.Contains("xbox"))
=> (int)g.Key.Family >= CURRENT_XBOX
&& g.Key.Family == family
&& g.Key.LabUrl.Contains("xbox"))
.SelectMany(g => g.Items)
.OrderByDescending(b => b.BuildTime)
.FirstOrDefault()

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -22,24 +21,23 @@ public RssController()
[Route("rss/compiled")]
public async Task<ActionResult> Index()
{
List<Build> builds = await _bModel.SelectBuildsByCompileDate(RSS_SIZE);
var builds = await _bModel.SelectBuildsByCompileDate(RSS_SIZE);
Feed feed = new Feed
var feed = new Feed
{
Title = "BuildFeed RSS - Recently Compiled",
Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}"),
Items = (from build in builds
select new Item
{
Title = build.AlternateBuildString,
Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}"),
Permalink = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}",
Categories =
{
build.Family.ToString()
},
PublishDate = DateTime.SpecifyKind(build.BuildTime.GetValueOrDefault(), DateTimeKind.Utc)
}).ToList()
select new Item
{
Title = build.AlternateBuildString,
Link = new Uri(
$"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}"),
Permalink =
$"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}",
Categories = build.RssCategories,
PublishDate = DateTime.SpecifyKind(build.BuildTime.GetValueOrDefault(), DateTimeKind.Utc)
}).ToList()
};
return new ContentResult
@ -53,24 +51,23 @@ public async Task<ActionResult> Index()
[Route("rss/added")]
public async Task<ActionResult> Added()
{
List<Build> builds = await _bModel.SelectBuildsByAddedDate(RSS_SIZE);
var builds = await _bModel.SelectBuildsByAddedDate(RSS_SIZE);
Feed feed = new Feed
var feed = new Feed
{
Title = "BuildFeed RSS - Recently Added",
Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}"),
Items = (from build in builds
select new Item
{
Title = build.AlternateBuildString,
Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}"),
Permalink = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}",
Categories =
{
build.Family.ToString()
},
PublishDate = DateTime.SpecifyKind(build.Added, DateTimeKind.Utc)
}).ToList()
select new Item
{
Title = build.AlternateBuildString,
Link = new Uri(
$"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}"),
Permalink =
$"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}",
Categories = build.RssCategories,
PublishDate = DateTime.SpecifyKind(build.Added, DateTimeKind.Utc)
}).ToList()
};
return new ContentResult
@ -84,24 +81,23 @@ public async Task<ActionResult> Added()
[Route("rss/leaked")]
public async Task<ActionResult> Leaked()
{
List<Build> builds = await _bModel.SelectBuildsByLeakedDate(RSS_SIZE);
var builds = await _bModel.SelectBuildsByLeakedDate(RSS_SIZE);
Feed feed = new Feed
var feed = new Feed
{
Title = "BuildFeed RSS - Recently Leaked",
Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}"),
Items = (from build in builds
select new Item
{
Title = build.AlternateBuildString,
Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}"),
Permalink = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}",
Categories =
{
build.Family.ToString()
},
PublishDate = DateTime.SpecifyKind(build.LeakDate.GetValueOrDefault(), DateTimeKind.Utc)
}).ToList()
select new Item
{
Title = build.AlternateBuildString,
Link = new Uri(
$"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}"),
Permalink =
$"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}",
Categories = build.RssCategories,
PublishDate = DateTime.SpecifyKind(build.LeakDate.GetValueOrDefault(), DateTimeKind.Utc)
}).ToList()
};
return new ContentResult
@ -115,23 +111,22 @@ public async Task<ActionResult> Leaked()
[Route("rss/version")]
public async Task<ActionResult> Version()
{
List<Build> builds = await _bModel.SelectBuildsByOrder(RSS_SIZE);
var builds = await _bModel.SelectBuildsByOrder(RSS_SIZE);
Feed feed = new Feed
var feed = new Feed
{
Title = "BuildFeed RSS - Highest Version",
Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}"),
Items = (from build in builds
select new Item
{
Title = build.AlternateBuildString,
Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}"),
Permalink = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}",
Categories =
{
build.Family.ToString()
}
}).ToList()
select new Item
{
Title = build.AlternateBuildString,
Link = new Uri(
$"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}"),
Permalink =
$"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}",
Categories = build.RssCategories
}).ToList()
};
return new ContentResult
@ -145,23 +140,22 @@ public async Task<ActionResult> Version()
[Route("rss/lab/{lab}")]
public async Task<ActionResult> Lab(string lab)
{
List<Build> builds = await _bModel.SelectLab(lab, RSS_SIZE);
var builds = await _bModel.SelectLab(lab, RSS_SIZE);
Feed feed = new Feed
var feed = new Feed
{
Title = $"BuildFeed RSS - {lab} Lab",
Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}"),
Items = (from build in builds
select new Item
{
Title = build.AlternateBuildString,
Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}"),
Permalink = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}",
Categories =
{
build.Family.ToString()
}
}).ToList()
select new Item
{
Title = build.AlternateBuildString,
Link = new Uri(
$"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}"),
Permalink =
$"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}",
Categories = build.RssCategories
}).ToList()
};
return new ContentResult