Skip to content

Commit

Permalink
Merge pull request #775 from euphorie/scrum-2800-report-with-exists-q…
Browse files Browse the repository at this point in the history
…ueries

Alternative fix for unanswered / not present risks
  • Loading branch information
ale-rt authored Dec 3, 2024
2 parents bc0e5c6 + a7617c7 commit 99447eb
Showing 1 changed file with 34 additions and 11 deletions.
45 changes: 34 additions & 11 deletions src/euphorie/client/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1907,13 +1907,23 @@ def _SKIPPED_MODULE_factory():

SKIPPED_MODULE = _SKIPPED_MODULE_factory()

UNANSWERED_RISKS_FILTER = sql.and_(
SurveyTreeItem.type == "risk",
sql.and_(
Risk.sql_risk_id == SurveyTreeItem.id,
Risk.identification == None, # noqa: E711
),
)

def _UNANSWERED_RISKS_FILTER_factory():
Risk_ = orm.aliased(Risk)
return sql.and_(
SurveyTreeItem.type == "risk",
sql.exists(
sql.select([Risk_.sql_risk_id]).where(
sql.and_(
Risk_.sql_risk_id == SurveyTreeItem.id,
Risk_.identification == None, # noqa: E711
)
)
),
)


UNANSWERED_RISKS_FILTER = _UNANSWERED_RISKS_FILTER_factory()


def _MODULE_WITH_UNANSWERED_RISKS_FILTER_factory():
Expand Down Expand Up @@ -1961,10 +1971,23 @@ def _MODULE_WITH_RISKS_NOT_PRESENT_FILTER_factory():

MODULE_WITH_RISKS_NOT_PRESENT_FILTER = _MODULE_WITH_RISKS_NOT_PRESENT_FILTER_factory()

RISK_NOT_PRESENT_FILTER = sql.and_(
SurveyTreeItem.type == "risk",
sql.and_(Risk.sql_risk_id == SurveyTreeItem.id, Risk.identification == "yes"),
)

def RISK_NOT_PRESENT_FILTER_factory():
Risk_ = orm.aliased(Risk)
return sql.and_(
SurveyTreeItem.type == "risk",
sql.exists(
sql.select([Risk_.sql_risk_id]).where(
sql.and_(
Risk_.sql_risk_id == SurveyTreeItem.id,
Risk_.identification == "yes",
)
)
),
)


RISK_NOT_PRESENT_FILTER = RISK_NOT_PRESENT_FILTER_factory()


def get_current_account():
Expand Down

0 comments on commit 99447eb

Please sign in to comment.