-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(companyData): enhance GET: /api/administration/companyData/missing-sd-document #1236
Conversation
1966764
to
97c5064
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did suggest a refactored query that should translate into the expected sql, but I suspect the data that is being selected is actually not correct as there is no guarantee that skipped process-steps refer to the most recent process-activity of the respective process. (In case a process is retriggered the previously created processStep instances in status skipped will just stay while a new processStep in status TODO is being created).
c.BusinessPartnerNumber, | ||
c.Name, | ||
c.Shortname, | ||
GetCompanyLastChangeDate(c) == null ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check is redundant - the expression translates into sql. On the database the selected column-value is just null in case the join of a table itself has no results.
Actually I'm surprised the corresponding test runs without error. I suspect this doesn't compile into SQL but runs on client-side. (the called static method also contains syntax that would not compile as the 'is' keyword is not supported within an expression).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like if one uses an method for the expression generation the check isn't working correctly. As soon as I moved the expression back to the origin I saw a warning.
{ | ||
ProcessStepTypeId: ProcessStepTypeId.START_SELF_DESCRIPTION_LP, | ||
ProcessStepStatusId: ProcessStepStatusId.SKIPPED | ||
})).FirstOrDefault(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as according to the database-schema there could be multiple matches just selecting the first without enforcing a specific order will eventually return an incorrect result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added the orderBy
ca.ApplicationChecklistEntries.Any(a => | ||
a.ApplicationChecklistEntryTypeId == ApplicationChecklistEntryTypeId.SELF_DESCRIPTION_LP && | ||
a.ApplicationChecklistEntryStatusId != ApplicationChecklistEntryStatusId.SKIPPED) && | ||
ca.ChecklistProcess!.ProcessSteps.Any(ps => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this condition is redundant to the Where-condition within the SelectMany. As this should compile into SQL (which I suppose it doesn't anyway) it will just create more complicated SQL with no runtime benefit.
GetCompanyLastChangeDate(c)!.DateLastChanged) | ||
).SingleOrDefaultAsync(); | ||
|
||
private static ProcessStep? GetCompanyLastChangeDate(Company company) => company.CompanyApplications.Where(ca => | ||
ca.ApplicationChecklistEntries.Any(a => | ||
a.ApplicationChecklistEntryTypeId == ApplicationChecklistEntryTypeId.SELF_DESCRIPTION_LP && | ||
a.ApplicationChecklistEntryStatusId != ApplicationChecklistEntryStatusId.SKIPPED) && | ||
ca.ChecklistProcess!.ProcessSteps.Any(ps => | ||
ps is | ||
{ | ||
ProcessStepTypeId: ProcessStepTypeId.START_SELF_DESCRIPTION_LP, | ||
ProcessStepStatusId: ProcessStepStatusId.SKIPPED | ||
})) | ||
.SelectMany(ca => ca.ChecklistProcess!.ProcessSteps.Where(ps => | ||
ps is | ||
{ | ||
ProcessStepTypeId: ProcessStepTypeId.START_SELF_DESCRIPTION_LP, | ||
ProcessStepStatusId: ProcessStepStatusId.SKIPPED | ||
})).FirstOrDefault(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetCompanyLastChangeDate(c)!.DateLastChanged) | |
).SingleOrDefaultAsync(); | |
private static ProcessStep? GetCompanyLastChangeDate(Company company) => company.CompanyApplications.Where(ca => | |
ca.ApplicationChecklistEntries.Any(a => | |
a.ApplicationChecklistEntryTypeId == ApplicationChecklistEntryTypeId.SELF_DESCRIPTION_LP && | |
a.ApplicationChecklistEntryStatusId != ApplicationChecklistEntryStatusId.SKIPPED) && | |
ca.ChecklistProcess!.ProcessSteps.Any(ps => | |
ps is | |
{ | |
ProcessStepTypeId: ProcessStepTypeId.START_SELF_DESCRIPTION_LP, | |
ProcessStepStatusId: ProcessStepStatusId.SKIPPED | |
})) | |
.SelectMany(ca => ca.ChecklistProcess!.ProcessSteps.Where(ps => | |
ps is | |
{ | |
ProcessStepTypeId: ProcessStepTypeId.START_SELF_DESCRIPTION_LP, | |
ProcessStepStatusId: ProcessStepStatusId.SKIPPED | |
})).FirstOrDefault(); | |
c.CompanyApplications | |
.Where(ca => | |
ca.ApplicationChecklistEntries.Any(a => | |
a.ApplicationChecklistEntryTypeId == ApplicationChecklistEntryTypeId.SELF_DESCRIPTION_LP && | |
a.ApplicationChecklistEntryStatusId != ApplicationChecklistEntryStatusId.SKIPPED)) | |
.SelectMany(ca => | |
ca.ChecklistProcess!.ProcessSteps.Where(ps => | |
ps.ProcessStepTypeId == ProcessStepTypeId.START_SELF_DESCRIPTION_LP && | |
ps.ProcessStepStatusId == ProcessStepStatusId.SKIPPED)) | |
.OrderByDescending(ps => ps.DateLastChanged) | |
.FirstOrDefault()!.DateLastChanged) |
…ng-sd-document Refs: #1179
2ba03da
to
0dcd9c8
Compare
0dcd9c8
to
fee93ee
Compare
Quality Gate passedIssues Measures |
Description
Add SdSkipped Date to GET: /api/administration/companyData/missing-sd-document
Why
To get an overview when the process was skipped
Issue
Refs: #1179
Checklist