Skip to content

Commit

Permalink
Merge branch 'feat-actors-badge' of https://github.com/Energinet-Data…
Browse files Browse the repository at this point in the history
…Hub/greenforce-frontend into feat-actors-badge
  • Loading branch information
dzhavat committed Aug 9, 2023
2 parents 18e1be1 + 69dda87 commit e3c7cfa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"**/node_modules/*/**": true
},
"prettier.prettierPath": "./node_modules/prettier",
"dotnet.defaultSolution": "apps/dh/api-dh/DataHub.WebApi.sln",
"eslint.validate": ["json"]
"eslint.validate": ["json"],
"dotnet.defaultSolution": "apps/dh/api-dh/DataHub.WebApi.sln"
}
26 changes: 24 additions & 2 deletions apps/dh/api-dh/source/DataHub.WebApi/GraphQL/GraphQLQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,30 @@ public GraphQLQuery()
});
});

Field<NonNullGraphType<ActorDtoType>>("actor")
.Argument<IdGraphType>("id", "The id of the actor")
.Resolve()
.WithScope()
.WithService<IMarketParticipantClient>()
.ResolveAsync(async (context, client) =>
{
var gridAreas = await client.GetGridAreasAsync();
var gridAreaLookup = gridAreas.ToDictionary(x => x.Id);
var actorDto = await client.GetActorAsync(context.GetArgument<Guid>("id"));
var actor = new Actor(actorDto.ActorId, actorDto.Name.Value, actorDto.ActorNumber.Value)
{
GridAreas = actorDto.MarketRoles
.SelectMany(marketRole => marketRole.GridAreas.Select(gridArea => gridArea.Id))
.Distinct()
.Select(gridAreaId => gridAreaLookup[gridAreaId])
.ToArray(),
MarketRole = actorDto.MarketRoles.FirstOrDefault()?.EicFunction,
Status = actorDto.Status,
};
return actor;
});

Field<NonNullGraphType<ListGraphType<NonNullGraphType<ActorDtoType>>>>("actors")
.Argument<EicFunction[]>("eicFunctions", true)
.Resolve()
Expand All @@ -237,8 +261,6 @@ public GraphQLQuery()
var accessibleActors = actors.Select(x => new Actor(x.ActorId, x.Name.Value, x.ActorNumber.Value)
{
Id = x.ActorId,
Name = x.Name.Value,
GlnOrEicNumber = x.ActorNumber.Value,
GridAreas = x.MarketRoles
.SelectMany(marketRole => marketRole.GridAreas.Select(gridArea => gridArea.Id))
Expand Down

0 comments on commit e3c7cfa

Please sign in to comment.