Return stations sorted
This commit is contained in:
parent
0b5a8bf487
commit
e4de0347ad
1 changed files with 7 additions and 1 deletions
|
@ -25,7 +25,13 @@ public class Database : Server.Services.Interfaces.IDatabase {
|
||||||
|
|
||||||
public DbRecord DbData { get; private set; } = new(3);
|
public DbRecord DbData { get; private set; } = new(3);
|
||||||
|
|
||||||
public IReadOnlyList<StationListing> Stations => stationListingsCollection.FindSync(_ => true).ToList();
|
public IReadOnlyList<StationListing> Stations => stationListingsCollection
|
||||||
|
.Aggregate(PipelineDefinition<StationListing, StationListing>.Create(
|
||||||
|
"{ $addFields: { stoppedAtCount: { $size: \"$stoppedAtBy\" } } }",
|
||||||
|
"{ $sort: { stoppedAtCount: -1 } }",
|
||||||
|
"{ $unset: \"stoppedAtCount\" }"
|
||||||
|
))
|
||||||
|
.ToList();
|
||||||
public IReadOnlyList<TrainListing> Trains => trainListingsCollection.FindSync(_ => true).ToList();
|
public IReadOnlyList<TrainListing> Trains => trainListingsCollection.FindSync(_ => true).ToList();
|
||||||
|
|
||||||
private static readonly string DbDir = Environment.GetEnvironmentVariable("DB_DIR") ?? Path.Join(Environment.CurrentDirectory, "db");
|
private static readonly string DbDir = Environment.GetEnvironmentVariable("DB_DIR") ?? Path.Join(Environment.CurrentDirectory, "db");
|
||||||
|
|
Loading…
Add table
Reference in a new issue