@@ -36,7 +36,10 @@ private string RetrieveApplicationCalculator
36
36
</filter>
37
37
<link-entity name=""ofm_intake"" from=""ofm_application_score_calculator"" to=""ofm_application_score_calculatorid"" link-type=""inner"" alias=""intake"">
38
38
<attribute name=""ofm_start_date"" />
39
- <attribute name=""ofm_end_date"" />
39
+ <attribute name=""ofm_end_date"" />
40
+ <filter>
41
+ <condition attribute=""statecode"" operator=""eq"" value=""0"" />
42
+ </filter>
40
43
</link-entity>
41
44
</entity>
42
45
</fetch>" ;
@@ -177,17 +180,24 @@ private IComparisonHandler comparisonChain
177
180
{
178
181
scores . Add ( scoreData ) ;
179
182
}
180
- }
181
-
182
- //Upsert Scores
183
- foreach ( var score in scores )
183
+ }
184
+
185
+
186
+
187
+ var existingScores = await dataverseRepository . GetApplicationScores ( applicationId ) ;
188
+
189
+
190
+ if ( ( existingScores == null || ! existingScores . Any ( ) ) || ( existingScores != null && existingScores . Any ( ) && existingScores . Where ( x => x . ApplicationScoreCalculatorId . Equals ( calculatorId ) ) . Any ( ) ) )
184
191
{
185
- _logger . LogInformation ( CustomLogEvent . Process , "Upsert Batch started for calculated scores for application {applicationId}" , applicationId ) ;
186
- await dataverseRepository . UpsertApplicationScoreAsync ( $ "_ofm_application_value={ applicationId } ,_ofm_application_score_category_value={ score [ "ofm_application_score_category@odata.bind" ] ? . ToString ( ) . Replace ( "ofm_application_score_categories" , "" ) . Replace ( "(" , "" ) . Replace ( ")" , "" ) } ", score ) ;
187
- _logger . LogInformation ( CustomLogEvent . Process , "Upsert Batch completed for calculated scores for application {applicationId}" , applicationId ) ;
192
+ //Upsert Scores
193
+ foreach ( var score in scores )
194
+ {
195
+ _logger . LogInformation ( CustomLogEvent . Process , "Upsert Batch started for calculated scores for application {applicationId}" , applicationId ) ;
196
+ await dataverseRepository . UpsertApplicationScoreAsync ( $ "_ofm_application_value={ applicationId } ,_ofm_application_score_category_value={ score [ "ofm_application_score_category@odata.bind" ] ? . ToString ( ) . Replace ( "ofm_application_score_categories" , "" ) . Replace ( "(" , "" ) . Replace ( ")" , "" ) } ", score ) ;
197
+ _logger . LogInformation ( CustomLogEvent . Process , "Upsert Batch completed for calculated scores for application {applicationId}" , applicationId ) ;
188
198
199
+ }
189
200
}
190
-
191
201
192
202
193
203
//commented due to timeout while processing batch
0 commit comments