Skip to content
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

[EdgeDB] - Add trigger to appropriately create financial/narrative report upon project creation #3279

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions dbschema/project.esdl
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,16 @@ module default {

trigger addRemovePeriodicReports after update for each
when (
__old__.mouStart != __new__.mouStart
or __old__.mouEnd != __new__.mouEnd
or __old__.financialReportPeriod != __new__.financialReportPeriod
__old__.mouStart ?!= __new__.mouStart
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CarsonF - I'm wondering if this is the place where we can also handle the case in which all 3 of these values exist for the first time? We could check if they've each changed, but also that none of them are null?

On a related note, can any of these values go back to null once set?

or __old__.mouEnd ?!= __new__.mouEnd
or __old__.financialReportPeriod ?!= __new__.financialReportPeriod
)
do (
with
existingReportPeriods := (
select FinancialReport
existingReports := (
select PeriodicReport
filter .container.id = __old__.id
).period,
),
interval := (
select (if __new__.financialReportPeriod = default::ReportPeriod.Monthly then '1' else '3')
),
Expand All @@ -174,13 +174,13 @@ module default {
__new__.mouEnd,
interval
)
if __old__.financialReportPeriod != __new__.financialReportPeriod (
select (if __old__.financialReportPeriod ?!= __new__.financialReportPeriod then (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CarsonF - I'm getting this error here.

Window_and_project_esdl_—_cord-api-v3

I'm trying to avoid ProgressReports here since that's a different flow. Any ideas on the best way to handle this?

with
reportPeriodsWithoutFiles := (
select existingReportPeriods
select existingReports
filter not exists .reportFile
),
deletedReportPeriods : = (
deletedReportPeriods := (
for reportPeriod in reportPeriodsWithoutFiles
union (
delete reportPeriod
Expand Down Expand Up @@ -213,14 +213,14 @@ module default {
with
requestedReportPeriodsForInsertion := (
select requestedReportPeriods
filter requestedReportPeriods not in existingReportPeriods
filter requestedReportPeriods not in existingReports.period
),
requestedReportPeriodsForDeletion := (
select existingReportPeriods
filter existingReportPeriods not in requestedReportPeriods
select existingReports.period
filter existingReports.period not in requestedReportPeriods
),
applicableReportPeriodsForDeletion := (
select PeriodicReport[is FinancialReport | NarrativeReport]
applicableReportsForDeletion := (
select PeriodicReport
filter .period in requestedReportPeriodsForDeletion
and not exists .reportFile
),
Expand All @@ -247,11 +247,13 @@ module default {
period := reportPeriod
})
))
for reportPeriod in applicableReportPeriodsForDeletion
for report in applicableReportsForDeletion
union (
delete reportPeriod
delete report
# filter report is typeof default::FinancialReport
# or report is typeof default::NarrativeReport
)
)
))
);
}

Expand Down
Loading