about summary refs log tree commit diff
path: root/OsuFederatedBeatmapApi/Controllers/BeatmapRepositoryController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OsuFederatedBeatmapApi/Controllers/BeatmapRepositoryController.cs')
-rw-r--r--OsuFederatedBeatmapApi/Controllers/BeatmapRepositoryController.cs31
1 files changed, 20 insertions, 11 deletions
diff --git a/OsuFederatedBeatmapApi/Controllers/BeatmapRepositoryController.cs b/OsuFederatedBeatmapApi/Controllers/BeatmapRepositoryController.cs
index 6c2bd31..6a1149d 100644
--- a/OsuFederatedBeatmapApi/Controllers/BeatmapRepositoryController.cs
+++ b/OsuFederatedBeatmapApi/Controllers/BeatmapRepositoryController.cs
@@ -1,24 +1,33 @@
 using Microsoft.AspNetCore.Mvc;
 using OsuFederatedBeatmapApi.Events.State;
+using OsuFederatedBeatmapApi.Services;
 
 namespace OsuFederatedBeatmapApi.Controllers;
 
 [ApiController]
 [Route("/")]
-public class BeatmapRepositoryController(ILogger<BeatmapRepositoryController> logger, ) : ControllerBase {
-
+public class BeatmapRepositoryController(ILogger<BeatmapRepositoryController> logger, FederatedBeatmapApiBotAccountDataService ads) : ControllerBase {
     [HttpGet("/beatmapset/all/info")]
     public async IAsyncEnumerable<BeatmapSetInfo> 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 IEnumerable<WeatherForecast> Get(int id) {
-		return Enumerable.Range(1, 5).Select(index => new WeatherForecast {
-				Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
-				TemperatureC = Random.Shared.Next(-20, 55),
-				Summary = Summaries[Random.Shared.Next(Summaries.Length)]
-			})
-			.ToArray();
-	}
+    [HttpGet("/beatmapset/{id:int}/info")]
+    public async Task<BeatmapSetInfo?> Get(int id) {
+        await ads.LoadAccountDataAsync();
+
+        foreach (var repo in ads.ListedRepositories) {
+            var states = await repo.GetStateAsync<BeatmapSetInfo>("gay.rory.beatmap_api.beatmap_set_info", id.ToString());
+            return states as BeatmapSetInfo;
+        }
+
+        return null;
+    }
 }