Skip to content

Commit

Permalink
feat: Summary submissions support (M2-5560) (#1466)
Browse files Browse the repository at this point in the history
* feature: flow assessments  and notes (M2-6584, M2-6585) (#1304)

* fix: Perform the Reviewers Assessment for Activity Flow

Allow to perform the Reviewers Assessment for the entire Activity Flow

* fix: Add unittests for flow's assessments

* fix: Add appletMeta to applet retrieve

appletMeta.hasAssessment attribute added to determine the existence of an assessment in an applet

* fix: Add notes to submission

New feature allows add notes for entire flow by submission id

* fix: Add submission id in data export

Added reviewedSubmissionId to data export

* fix: Fix comments

* fix: Changed field name in export

* fix: Add index

* fix: Fix assessment retrieve

* fix: Fix assessment retrieve rights

* fix: Submission rights check

* fix: Add submission reviews list

* fix: Note rights error

* fix: Method name

* wip: Split assessments list and retrieve for activity and flow methods (M2-6584)

* wip[flow assessments]:  fixes after merge (M2-6584)

* wip[flow assessments]:  fix reviewed_flow_submit_id

* wip[flow assessments]:  fix reviews for flow

* wip[flow assessments]:  remove case from query

* wip[flow assessments]:  fix comments

* feature(flow's latest report): Latest report (combined) support for flows (#1372)

* fix(flow-submission): Fix flow submission endpoints filtering out incomplete submissions(M2-6616) (#1378)

* fix(notes): Add user.id to note list (#1406)

* fix(responses): Fix for emptyIdentifiers filter (#1418)

* fix(summary): Fix getting versions, identifiers, submissions for deleted flows (m2-7030) (#1453)

* fix(summary): Fix getting versions, identifiers, submissions for fdeleted flows

* (wip): Using id instead id_version for join

---------

Co-authored-by: vshvechko <[email protected]>
  • Loading branch information
iwankrshkin and vshvechko authored Jun 26, 2024
1 parent 959334f commit 2ecbff7
Show file tree
Hide file tree
Showing 22 changed files with 1,728 additions and 151 deletions.
4 changes: 4 additions & 0 deletions src/apps/activities/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,7 @@ class FlowItemActivityKeyNotFoundError(ValidationError):

class MultiSelectNoneOptionError(ValidationError):
message = _("No more than 1 none option is not allowed for multiselect.")


class FlowDoesNotExist(NotFoundError):
message = _("Flow does not exist.")
18 changes: 15 additions & 3 deletions src/apps/activity_flows/crud/flow_history.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import uuid

from pydantic import parse_obj_as
from sqlalchemy import any_, select
from sqlalchemy import and_, any_, select
from sqlalchemy.orm import Query, joinedload

from apps.activities.db.schemas import ActivityHistorySchema
Expand Down Expand Up @@ -100,18 +100,30 @@ async def get_last_histories_by_applet(self, applet_id: uuid.UUID) -> list[Activ
db_result = await self._execute(query)
return db_result.scalars().all()

async def get_versions_data(self, flow_id: uuid.UUID) -> list[Version]:
async def get_versions_data(self, applet_id: uuid.UUID, flow_id: uuid.UUID) -> list[Version]:
query: Query = (
select(
AppletHistorySchema.version,
AppletHistorySchema.created_at,
)
.select_from(ActivityFlowHistoriesSchema)
.join(AppletHistorySchema, AppletHistorySchema.id_version == ActivityFlowHistoriesSchema.applet_id)
.join(
AppletHistorySchema,
and_(
AppletHistorySchema.id_version == ActivityFlowHistoriesSchema.applet_id,
AppletHistorySchema.id == applet_id,
),
)
.where(ActivityFlowHistoriesSchema.id == flow_id)
.order_by(AppletHistorySchema.created_at)
)
result = await self._execute(query)
data = result.all()

return parse_obj_as(list[Version], data)

async def get_list_by_id(self, id_: uuid.UUID) -> list[ActivityFlowHistoriesSchema]:
query: Query = select(ActivityFlowHistoriesSchema)
query = query.where(ActivityFlowHistoriesSchema.id == id_)
result = await self._execute(query)
return result.scalars().all()
4 changes: 2 additions & 2 deletions src/apps/activity_flows/service/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,5 +285,5 @@ async def get_info_by_applet_id(self, applet_id: uuid.UUID, language: str) -> li
flow_map[schema.activity_flow_id].activity_ids.append(schema.activity_id)
return flows

async def get_versions(self, flow_id: uuid.UUID) -> list[Version]:
return await FlowsHistoryCRUD(self.session).get_versions_data(flow_id)
async def get_versions(self, applet_id: uuid.UUID, flow_id: uuid.UUID) -> list[Version]:
return await FlowsHistoryCRUD(self.session).get_versions_data(applet_id, flow_id)
Loading

0 comments on commit 2ecbff7

Please sign in to comment.