@@ -9,13 +9,13 @@ namespace PrismaApi.Application.Services;
99public class FastApiService : IFastApiService
1010{
1111 private readonly HttpClient _httpClient ;
12- private readonly IProjectService _projectService ;
12+ private readonly IInfluenceDiagramService _influenceDiagramService ;
1313 private readonly IConfiguration _configuration ;
14- public FastApiService ( HttpClient httpClient , IProjectService projectService , IConfiguration configuration )
14+ public FastApiService ( HttpClient httpClient , IInfluenceDiagramService influenceDiagramService , IConfiguration configuration )
1515 {
1616 _httpClient = httpClient ;
1717 _httpClient . Timeout = TimeSpan . FromSeconds ( 180 ) ;
18- _projectService = projectService ;
18+ _influenceDiagramService = influenceDiagramService ;
1919 _configuration = configuration ;
2020 }
2121
@@ -56,28 +56,22 @@ public async Task<ApiResponseDto> CallDownstreamFastApiPostAsync(string endpoint
5656
5757 public async Task < ApiResponseDto > SendInfluenceDiagramToFastApiAsync ( Guid projectId , string endpoint , UserOutgoingDto user , CancellationToken ct = default )
5858 {
59- var influenceDiagram = await _projectService . GetInfluenceDiagramAsync ( projectId , user , ct ) ;
60- // make a clone to avoid mutating the chached influence diagram in the project service
61- var influenceDiagramClone = influenceDiagram . DeepClone ( ) ;
62- influenceDiagramClone . ApplyRestrictions ( ) ;
63- var content = new StringContent ( JsonSerializer . Serialize ( influenceDiagramClone ) , Encoding . UTF8 , "application/json" ) ;
59+ var influenceDiagram = await _influenceDiagramService . GetRestrictedInfluenceDiagramAsync ( projectId , user , ct ) ;
60+ var content = new StringContent ( JsonSerializer . Serialize ( influenceDiagram ) , Encoding . UTF8 , "application/json" ) ;
6461 return await CallDownstreamFastApiPostAsync ( endpoint , content , ct ) ;
6562 }
6663
6764 public async Task < ApiResponseDto > SendPartialInfluenceDiagramToFastApiAsync ( Guid projectId , string endpoint , List < List < Guid > > paths , UserOutgoingDto user , CancellationToken ct = default )
6865 {
69- var influenceDiagram = await _projectService . GetInfluenceDiagramAsync ( projectId , user , ct ) ;
70- // make a clone to avoid mutating the chached influence diagram in the project service
71- var influenceDiagramClone = influenceDiagram . DeepClone ( ) ;
72- influenceDiagramClone . ApplyRestrictions ( ) ;
66+ var influenceDiagram = await _influenceDiagramService . GetRestrictedInfluenceDiagramAsync ( projectId , user , ct ) ;
7367
7468 var payload = new
7569 {
76- issues = influenceDiagramClone . issues ,
77- edges = influenceDiagramClone . edges ,
78- discrete_probabilities = influenceDiagramClone . discreteProbabilities ,
79- discrete_utilities = influenceDiagramClone . discreteUtilities ,
80- restriction_tables = influenceDiagramClone . restrictionTables ,
70+ issues = influenceDiagram . issues ,
71+ edges = influenceDiagram . edges ,
72+ discrete_probabilities = influenceDiagram . discreteProbabilities ,
73+ discrete_utilities = influenceDiagram . discreteUtilities ,
74+ restriction_tables = influenceDiagram . restrictionTables ,
8175 paths
8276 } ;
8377 var content = new StringContent ( JsonSerializer . Serialize ( payload ) , Encoding . UTF8 , "application/json" ) ;
@@ -86,18 +80,15 @@ public async Task<ApiResponseDto> SendPartialInfluenceDiagramToFastApiAsync(Guid
8680
8781 public async Task < ApiResponseDto > SendInfluenceDiagramWithEvidenceToFastApiAsync ( Guid projectId , string endpoint , List < EvidenceRequestDto > data , UserOutgoingDto user , CancellationToken ct = default )
8882 {
89- var influenceDiagram = await _projectService . GetInfluenceDiagramAsync ( projectId , user , ct ) ;
90- // make a clone to avoid mutating the chached influence diagram in the project service
91- var influenceDiagramClone = influenceDiagram . DeepClone ( ) ;
92- influenceDiagramClone . ApplyRestrictions ( ) ;
83+ var influenceDiagram = await _influenceDiagramService . GetRestrictedInfluenceDiagramAsync ( projectId , user , ct ) ;
9384
9485 var payload = new
9586 {
96- issues = influenceDiagramClone . issues ,
97- edges = influenceDiagramClone . edges ,
98- discrete_probabilities = influenceDiagramClone . discreteProbabilities ,
99- discrete_utilities = influenceDiagramClone . discreteUtilities ,
100- restriction_tables = influenceDiagramClone . restrictionTables ,
87+ issues = influenceDiagram . issues ,
88+ edges = influenceDiagram . edges ,
89+ discrete_probabilities = influenceDiagram . discreteProbabilities ,
90+ discrete_utilities = influenceDiagram . discreteUtilities ,
91+ restriction_tables = influenceDiagram . restrictionTables ,
10192 evidence = data ,
10293 } ;
10394 var content = new StringContent ( JsonSerializer . Serialize ( payload ) , Encoding . UTF8 , "application/json" ) ;
0 commit comments