mirror of
https://gitlab.com/buildfeed/BuildFeed.git
synced 2024-03-22 21:10:34 +08:00
It's fixed and I haven't topped myself
I guess this counts as "exceeds expectations"
This commit is contained in:
parent
53b89fb161
commit
74a0e83ea8
|
@ -54,19 +54,22 @@ public async Task<List<BuildModel>> SelectVersion(int major, int minor, int skip
|
||||||
public async Task<List<BuildVersion>> SelectVersions()
|
public async Task<List<BuildVersion>> SelectVersions()
|
||||||
{
|
{
|
||||||
var result = await _buildCollection.Aggregate()
|
var result = await _buildCollection.Aggregate()
|
||||||
.Group(b => new BuildVersion()
|
// the group method in mongodb's c# driver sucks balls and throws a hissy fit over far too much.
|
||||||
{
|
.Group(b => new BuildVersion(b.MajorVersion, b.MinorVersion), bg => new BsonDocument())
|
||||||
Major = b.MajorVersion,
|
|
||||||
Minor = b.MinorVersion,
|
|
||||||
},
|
|
||||||
// incoming bullshit hack
|
|
||||||
bg => new Tuple<BuildVersion>(bg.Key))
|
|
||||||
.SortByDescending(b => b.Item1.Major)
|
|
||||||
.ThenByDescending(b => b.Item1.Minor)
|
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
// work ourselves out of aforementioned bullshit hack
|
// work ourselves out of aforementioned bullshit hack
|
||||||
return result.Select(b => b.Item1).ToList();
|
var typed = from r in result
|
||||||
|
select new BuildVersion
|
||||||
|
{
|
||||||
|
Major = (byte)result.First()["_id"]["Major"].ToInt32(),
|
||||||
|
Minor = (byte)result.First()["_id"]["Minor"].ToInt32()
|
||||||
|
};
|
||||||
|
|
||||||
|
return (from t in typed
|
||||||
|
orderby t.Major descending,
|
||||||
|
t.Minor descending
|
||||||
|
select t).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
[DataObjectMethod(DataObjectMethodType.Select, false)]
|
[DataObjectMethod(DataObjectMethodType.Select, false)]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user