configure grpc

This commit is contained in:
2026-01-17 18:08:16 -05:00
parent fc80e50c26
commit b762139243
27 changed files with 467 additions and 500 deletions

View File

@@ -0,0 +1,44 @@
using AZKiServer.Models;
using MongoDB.Driver;
using System.Collections.Frozen;
namespace AZKiServer.Services;
public class MediaService(IMongoDatabase db)
{
public readonly IMongoCollection<MediaEntry> _entries = db.GetCollection<MediaEntry>("media");
public async Task<FrozenSet<string>> GetExistingFilePathsAsync(CancellationToken cancellationToken = default)
{
var files = await _entries.Find("{}").Project(m => m.Filepath).ToListAsync(cancellationToken);
return files.ToFrozenSet();
}
public async Task AddMediaBulkAsync(List<MediaEntry> entries, CancellationToken cancellationToken = default)
{
await _entries.InsertManyAsync(entries, cancellationToken: cancellationToken);
}
public async Task<List<MediaEntry>> GetEntriesInRangeAsync(MediaType mediaType, DateTime from, DateTime to)
{
var filter = Builders<MediaEntry>.Filter
.And([
Builders<MediaEntry>.Filter.BitsAnySet(m => m.Type, (long)mediaType),
Builders<MediaEntry>.Filter.Gte(m => m.Date, from),
Builders<MediaEntry>.Filter.Lte(m => m.Date, to),
]);
return _entries.Find(filter).ToList();
}
public class IndexCreation : BackgroundService
{
protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
throw new NotImplementedException();
}
}
}