-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GetProgressionsIndex operation implemented
- Loading branch information
1 parent
74373c0
commit 4d28da5
Showing
9 changed files
with
68 additions
and
5 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
HarmonyDB.Index/HarmonyDB.Index.Api/Functions/V1/GetProgressionsIndex.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using HarmonyDB.Index.Api.Services; | ||
using HarmonyDB.Index.DownstreamApi.Client; | ||
using HarmonyDB.Source.Api.Model; | ||
using HarmonyDB.Source.Api.Model.VInternal; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Azure.Functions.Worker; | ||
using Microsoft.Extensions.Logging; | ||
using OneShelf.Common.Api; | ||
|
||
namespace HarmonyDB.Index.Api.Functions.V1; | ||
|
||
public class GetProgressionsIndex : FunctionBase<GetProgressionsIndexRequest, GetProgressionsIndexResponse> | ||
{ | ||
private readonly DownstreamApiClient _downstreamApiClient; | ||
|
||
public GetProgressionsIndex(ILoggerFactory loggerFactory, DownstreamApiClient downstreamApiClient) | ||
: base(loggerFactory) | ||
{ | ||
_downstreamApiClient = downstreamApiClient; | ||
} | ||
|
||
[Function(SourceApiUrls.VInternalGetProgressionsIndex)] | ||
public Task<IActionResult> Run( | ||
[HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequest req, [FromBody] GetProgressionsIndexRequest request) | ||
=> RunHandler(request); | ||
|
||
protected override async Task<GetProgressionsIndexResponse> Execute(GetProgressionsIndexRequest request) | ||
{ | ||
var results = (await Task.WhenAll(_downstreamApiClient.GetDownstreamSourceIndices(x => x.AreProgressionsProvidedForIndexing) | ||
.Select(_downstreamApiClient.VInternalGetProgressionsIndex))) | ||
.SelectMany(x => x.Progressions) | ||
.ToDictionary(x => x.Key, x => x.Value); | ||
|
||
return new() | ||
{ | ||
Progressions = results, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
HarmonyDB.Source/HarmonyDB.Source.Api.Model/VInternal/GetProgressionsIndexRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace HarmonyDB.Source.Api.Model.VInternal; | ||
|
||
public class GetProgressionsIndexRequest | ||
{ | ||
} |
8 changes: 8 additions & 0 deletions
8
HarmonyDB.Source/HarmonyDB.Source.Api.Model/VInternal/GetProgressionsIndexResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using HarmonyDB.Index.Analysis.Models.CompactV1; | ||
|
||
namespace HarmonyDB.Source.Api.Model.VInternal; | ||
|
||
public class GetProgressionsIndexResponse | ||
{ | ||
public required IReadOnlyDictionary<string, CompactChordsProgression> Progressions { get; init; } | ||
} |