Skip to content

Commit

Permalink
Merge pull request #773 from euphorie/scrum-2800-report-not-present-r…
Browse files Browse the repository at this point in the history
…isks

Fix query for risks that are not present
  • Loading branch information
reinhardt authored Nov 25, 2024
2 parents f2ddfcc + 75e5d84 commit 7fb7090
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 32 deletions.
7 changes: 3 additions & 4 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Changelog
16.2.5 (unreleased)
-------------------

- Nothing changed yet.
- Report: Fix lists of risks (“parked” / not present)
(`#2800 <https://github.com/syslabcom/scrum/issues/2800>`_)
[reinhardt]


16.2.4 (2024-11-21)
Expand All @@ -16,9 +18,6 @@ Changelog
- Action Plan: Strip HTML from comments
(`#2763 <https://github.com/syslabcom/scrum/issues/2763>`_)
[reinhardt]
- Report: Fix “parked” risks
(`#2800 <https://github.com/syslabcom/scrum/issues/2800>`_)
[reinhardt]


16.2.3 (2024-10-25)
Expand Down
8 changes: 1 addition & 7 deletions src/euphorie/client/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1963,13 +1963,7 @@ def _MODULE_WITH_RISKS_NOT_PRESENT_FILTER_factory():

RISK_NOT_PRESENT_FILTER = 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"
)
)
),
sql.and_(Risk.sql_risk_id == SurveyTreeItem.id, Risk.identification == "yes"),
)


Expand Down
51 changes: 30 additions & 21 deletions src/euphorie/client/tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# from euphorie.client.report import IdentificationReport
# from euphorie.content.risk import Risk
from euphorie.client import model
from euphorie.client import utils
from euphorie.client.adapters.session_traversal import TraversedSurveySession
from euphorie.client.interfaces import IClientSkinLayer
from euphorie.client.model import SurveySession
Expand All @@ -12,7 +13,6 @@
from ExtensionClass import Base
from plone import api
from plone.app.testing.interfaces import SITE_OWNER_NAME
from sqlalchemy import sql
from unittest import mock
from urllib.parse import quote
from z3c.saconfig import Session
Expand Down Expand Up @@ -520,29 +520,11 @@ def test_render_value(self):
)


def get_unanswered_nodes(session):
query = (
Session()
.query(model.SurveyTreeItem)
.filter(
sql.and_(
model.SurveyTreeItem.session == session,
sql.or_(
model.MODULE_WITH_UNANSWERED_RISKS_FILTER,
model.UNANSWERED_RISKS_FILTER,
),
sql.not_(model.SKIPPED_PARENTS),
)
)
.order_by(model.SurveyTreeItem.path)
)
return query.all()


class UnansweredQueryTests(EuphorieIntegrationTestCase):
"""Test #2800.
Only risks with `identification` == None are returned as unanswered.
They are not returned as not present.
"""

def createData(self):
Expand Down Expand Up @@ -598,6 +580,24 @@ def createData(self):
)
self.mod1.addChild(self.r1)

self.r3 = model.Risk(
**{
"risk_id": 2,
"depth": 3,
"identification": "yes",
"action_plans": [],
"has_description": True,
"path": "001001002",
"postponed": False,
"profile_index": 0,
"skip_children": False,
"title": "Feet are washed",
"type": "risk",
"zodb_path": "173/euphorie.risk-1",
}
)
self.mod1.addChild(self.r3)

self.mod2 = model.Module(
**{
"depth": 2,
Expand Down Expand Up @@ -636,7 +636,16 @@ def testUnansweredNodes(self):
self.createData()
risks = [
node
for node in get_unanswered_nodes(self.survey_session)
for node in utils.get_unanswered_nodes(self.survey_session)
if node.type == "risk"
]
self.assertEqual(len(risks), 1)

def testRiskNotPresentNodes(self):
self.createData()
risks = [
node
for node in utils.get_risk_not_present_nodes(self.survey_session)
if node.type == "risk"
]
self.assertEqual(len(risks), 1)

0 comments on commit 7fb7090

Please sign in to comment.