-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
backend/LexBoxApi/GraphQL/CustomTypes/IsLanguageForgeProjectDataLoader.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,30 @@ | ||
using LexCore.ServiceInterfaces; | ||
using LfClassicData; | ||
using MongoDB.Driver; | ||
using MongoDB.Driver.Linq; | ||
|
||
namespace LexBoxApi.GraphQL.CustomTypes; | ||
|
||
public class IsLanguageForgeProjectDataLoader : BatchDataLoader<string, bool>, IIsLanguageForgeProjectDataLoader | ||
{ | ||
private readonly SystemDbContext _systemDbContext; | ||
|
||
public IsLanguageForgeProjectDataLoader( | ||
SystemDbContext systemDbContext, | ||
IBatchScheduler batchScheduler, | ||
DataLoaderOptions? options = null) | ||
: base(batchScheduler, options) | ||
{ | ||
_systemDbContext = systemDbContext; | ||
} | ||
|
||
protected override async Task<IReadOnlyDictionary<string, bool>> LoadBatchAsync( | ||
IReadOnlyList<string> projectCodes, | ||
CancellationToken cancellationToken) | ||
{ | ||
return await MongoExtensions.ToAsyncEnumerable(_systemDbContext.Projects.AsQueryable() | ||
.Select(p => p.ProjectCode) | ||
.Where(projectCode => projectCodes.Contains(projectCode))) | ||
Check warning on line 27 in backend/LexBoxApi/GraphQL/CustomTypes/IsLanguageForgeProjectDataLoader.cs GitHub Actions / Build API / publish-api
|
||
.ToDictionaryAsync(projectCode => projectCode, _ => true, cancellationToken); | ||
} | ||
} |
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
6 changes: 6 additions & 0 deletions
6
backend/LexCore/ServiceInterfaces/IIsLanguageForgeProjectDataLoader.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,6 @@ | ||
namespace LexCore.ServiceInterfaces; | ||
|
||
public interface IIsLanguageForgeProjectDataLoader | ||
{ | ||
public Task<bool> LoadAsync(string projectCode, CancellationToken cancellationToken = default); | ||
} |
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