using Microsoft.AspNetCore.Mvc; using OsuFederatedBeatmapApi.Events.State; using OsuFederatedBeatmapApi.Services; namespace OsuFederatedBeatmapApi.Controllers; [ApiController] [Route("/")] public class BeatmapRepositoryController(ILogger logger, FederatedBeatmapApiBotAccountDataService ads, BeatmapFetcherService bfs) : ControllerBase { [HttpGet("/beatmapset/all/info")] public async IAsyncEnumerable GetAllInfo() { await ads.LoadAccountDataAsync(); foreach (var repo in ads.ListedRepositories) { var states = repo.GetFullStateAsync(); await foreach (var state in states) { if (state?.TypedContent is BeatmapSetInfo info) yield return info; } } } [HttpGet("/beatmapset/{id:int}/info")] public async Task Get(int id) { await ads.LoadAccountDataAsync(); foreach (var repo in ads.ListedRepositories) { var state = await repo.GetStateOrNullAsync("gay.rory.beatmap_api.beatmap_set_info", id.ToString()); if (state is not null) return state; return await bfs.FetchBeatmapSetInfo(id); } return null; } }