Skip to content

Commit

Permalink
Loris integration phase 2 pull develop da6e8cb (#1630)
Browse files Browse the repository at this point in the history
* feat: Add/Update endpoint to retrieve activities assigned to a participant (M2-6223) (#1565)

This PR adds a new endpoint `/activities/applet/{applet_id}/subject/{subject_id}`, which allows the caller to fetch an object containing the list of activities and activity flows that have been assigned to the subject specified by `subject_id` in some way. Each activity or flow will have a non-nullable array property called `assignments` containing the list of assignments of that activity/flow where the given subject is the **respondent**.

It is yet undecided at a product level whether auto assigned activities/flows can be manually assigned, but the API currently allows this. Thus, it is possible for the data returned from this endpoint to contain an activity/flow with both `autoAssign` set to `true`, and a non-empty `assignments` property.

The caller of the endpoint must be authenticated as a user with one of the following user roles:
- Owner
- Manager
- Coordinator
- Reviewer (with access to the subject)

* feat: unassign activity or flow endpoint (M2-7358) (#1556)

This pull request introduces the unassign endpoint for activity assignments. The unassign functionality allows authorized users to mark assignments as deleted. It ensures that previously assigned activities or flows can be unassigned, effectively updating the database to reflect the unassignment.

* feature: Completed unassign endpoint using the same json structure of the assign assignments endpoint request. Implemented get_assignments_by_activity_or_flow_id_and_subject_id to retrieve assignment_id using activity_id and subject_id. Crated unassign_many to update multiple schemas at a time using the _update CRUD base function
* Calling assignment endpoint and then unassign to test functionality
* Created tests for unassign feature
* Recover applet_assignments function and completed unassign_many function
* Typing consistency for delete requests and Optional types on unassign feature
* Update src/apps/activity_assignments/router.py

Co-authored-by: Farmer Paul <[email protected]>

---------

Co-authored-by: Farmer Paul <[email protected]>

* fix: add `items` to assigned activities endpoint (#1591)

* fix: Return assignments matching either respondent or target subject ID (M2-6223) (#1592)

* fix: match by both respondent & target subject

Assignments being returned by this endpoint were only matching by
respondent subject, but the AC for M2-6223 states to return assignments
matching both by respondent & target subject. So adjusted the function
to match by one of those, or both, based on the `match_by` parameter.

Fixed tests to test this condition as well.

* fix: remove redundant CRUD function

The `check_for_assignment_and_notify` function was using a CRUD function
`get_by_respondent_subject_id` to return assignments matching a given
respondent subject, which did not perform soft-delete integrity checks.
The same functionality exists in `get_by_applet_and_subject` but with
soft-delete integrity checks, so removed the old function in favour of
this one.

* refactor: use `Filters` class, simplify code

On @rcmerlo's recommendation, switched to using `QueryParams` and
`Filters` class for filtering assignments queries by respondent or
target subject. In doing so, discovered that `get_by_applet_and_subject`
was not in fact needed; all the functionality is now provided by
`get_by_applet`.

* Deploy to dev

* Deploy to dev 2

* Fix

* Update ECS task runner

* Run migrations on startup (#1593)

* Created new startup script

* testing env

* feature env version

* feature start manifest

* M2-7550 Disabling OASDiff

* Dev build/deploy

* Fix dev build

* Disabling OASDIFF

* Add support to Unity activity type (M2-7441)  (#1563)

* feat: adding unity type

* change to fix odd validation behavior on item responses

* refactor unityFile to unity

* ruff formatting

* ruff linting import order change

* Adding unity tests

* ruff format

* test name fix

* re-adding wrongly removed test

* moving unity file file to config

---------

Co-authored-by: Ramir Mesquita <[email protected]>

* Fix: tests for Unity activity item (#1597)

* feat: Add `severity` field to subscale lookup table (M2-7586) (#1596)

This PR adds a field called `severity` to the subscale lookup table JSONB data. This allows subscale lookup tables to be saved with severity data

* feature: Handle reassign an assignment in creation endpoint (M2-7461) (#1594)

* chore: Update some dependencies to fix some security issues

* feature: Handle reassign an assignment in creation endpoint (M2-7461)

* Refatoring assignments service and crud to use upsert

* chore: Move assignments tests to one file to remove duplicated fixtures

* add passed tests to the slack output steps

* feature: Soft delete activity assignments on activity/flow deletion (#1598)

* fix: Modified answers applet_validate_multiinformant_assessment api (M2-6978) (#1581)

Modified answers applet_validate_multiinformant_assessment api to return BAD REQUEST instead of 200 OK response using pydantic validation and modified the answers tests script to validate new responses.

* Update: README and .env template in relation to onboarding (#1606)

* Update CORS ALLOW ORIGIN env variables to match any localhost pattern. Update MAILING__MAIL__SERVER to 'mailhog'.

* Update README with steps related to running API locally.

* Additional notes

* spelling

* feat: Update Subscale Lookup Table to support age ranges (M2-7586) (#1604)

This PR updates the validation for the subscale lookup table to support ranges in the `age` field using the tilde character (~), similar to the `score` and `rawScore` fields.

* feat: Get Subjects by Respondent Subject: Submissions + Assignments (M2-7919) (#1611)

This PR creates the new endpoint `/subjects/respondent/{respondent_subject_id}/activity-or-flow/{activity_or_flow_id}`, which returns a list of subjects based on an association with the respondent subject and activity/flow specified. The endpoint is accessible by users with the following applet roles:
- Owner
- Manager
- Coordinator
- Reviewer (who is assigned the `respondent_subject_id` subject)

Each subject in the list returned will be the target subject of at least one:
- Assignment where `respondent_subject_id` is the respondent subject (including auto-assigned activities/flows)
- Submission where `respondent_subject_id` is the source subject

In addition to the usual `SubjectReadResponse` properties, there are two extra ones that I'd like to highlight:
- `submissionCount`: This is the number of answers that the respondent has submitted for a given subject and activity/flow
- `currentlyAssigned`: Whether the activity/flow is currently assigned for the respondent to complete about a given subject

Activities/flows that have been unassigned and don't have any submissions aren't included

* feat: Add endpoint to get activities/flows assigned to or submitted for target (M2-7853) (#1614)

This PR creates the new endpoint `GET /activities/applet/{applet_id}/target/{subject_id}`, which returns a list of activities and flows that are associated with the specified target subject within the applet. The endpoint is accessible by users with the following applet roles:

- Owner
- Manager
- Coordinator
- Reviewer (who is assigned the target subject)

Each activity/flow in the list will be returned based on one of the following conditions
- The activity/flow is set to auto assign
- The activity/flow is manually assigned to some respondent, with the specified target subject as its target
- Answers have been submitted at some point in the past for the activity/flow with the specified target subject as the target

The return type is `ActivityOrFlowWithAssignmentsPublic`

---------

Co-authored-by: Rodrigo Merlo <[email protected]>

* chore: Fix syntax error in e2e-tests.yaml

* feat: implement endpoints for respondent activities

* fix: some typo

* fix: check for limited account respondents

* chore: fix typing and formatting

* chore: change cq target to only check and not format

* feature: extend the list of supported item types 

* feature(conditionalLogic): Accept new activity items

* wip(conditionalLogic): DateItem support

* wip(conditionalLogic): time and timerange added

* wip(conditionalLogic) Fix validation errors for time an date

* wip(sliderRow): Add slider row validation

* wip(conditionalLogic) Remove type from tume renge

* wip(conditionalLogic): allow all activity items types

* wip(conditionalLogic): Split score and reports and conditionalLogic

* wip(conditionalLogic): Add special public model

* wip(conditionalLogic): Change index type

* wip(conditionalLogic): Change option based items validation

* feature/new_items_types

* chore/fixing code quality

* chore/fixing singleTimePayload, minMaxTimePayload, activity_item_change on code quality and fixing date test on test_custom_validation

* chore/cleaning test_custom_validation comment

* chore/ruff format condition.py and test_custom_validation

---------

Co-authored-by: ivan koryshkin <[email protected]>
Co-authored-by: iwankrshkin <[email protected]>
Co-authored-by: Felipe Imperio <[email protected]>

* feat(applet-duplication): add optional report server config flag (M2-7830) (#1623)

This PR updates the applet duplication endpoint to optionally include an optional `include_report_server` property that defaults to false (making it backwards compatible).

The following properties are duplicated:
- `reportServerIp`
- `reportPublicKey`
- `reportIncludeUserId`
- `reportIncludeCaseId`
- `reportEmailBody`

* chore: Change report server contract (M2-7481,M2-7483) (#1584)

* fix: Downgrade boto3 to version 1.26.10 (M2-8020) (#1627)

* feat: add Greek email templates (M2-7665) (#1624)

* chore: add language assertion to invitation tests

* fix: tom's fixture function return type

* chore: rename mailing service html template getter

* fix: shell account re-invite unit test

* chore: parameterize invitation unit tests

* chore: fix html email template formatting

* feat: implement fallback to English for localized email templates

* feat: add placeholder templates for greek emails

* fix: lints

* fix: some typing errors in invitation unit tests

* chore: replace placeholder with actual greek translations

* chore: rename parameter names for email template function

* chore: add tests for assignment email language

---------

Co-authored-by: Billie He <[email protected]>

* chore: Update python version to 3.11 (#1622)

* chore: Update python version to 3.11

* chore: Getting away from passlib and using bcrypt directly

* chore: Moving from python-jose  lib to pyJWT

* fix: Rebase and fix pipfile.lock

* M2-7905 DR Add tag push stage to Github actions builds for DR ECR (#1625)

* Adding DR ECR

* extra output

* fixed region

* fix: fixing two alembic heads with `alembic merge heads`

* feat:  use scores or raw scores for report server processing (M2-7933) (#1616)

* Changes Score class allowing two new arguments:  scoring_type and sucale_name and verifies that data is saved into the DataBase, then retriving it when create_report is executed. 
* Fixed issues with SinglePayload class and adjusted tests accordingly.

* fix: fixing ScoringType

---------

Co-authored-by: Kenroy Gobourne <[email protected]>
Co-authored-by: AlejandroCoronadoN <[email protected]>
Co-authored-by: Farmer Paul <[email protected]>
Co-authored-by: Carlos Chacon <[email protected]>
Co-authored-by: Andrew Weiland <[email protected]>
Co-authored-by: Ramir Mesquita <[email protected]>
Co-authored-by: Ramir Mesquita <[email protected]>
Co-authored-by: Rodrigo Colao Merlo <[email protected]>
Co-authored-by: Phillipe Bojorquez <[email protected]>
Co-authored-by: Shaunna Samuels <[email protected]>
Co-authored-by: Phillipe Bojorquez <[email protected]>
Co-authored-by: Billie He <[email protected]>
Co-authored-by: Billie He <[email protected]>
Co-authored-by: felipeMetaLab <[email protected]>
Co-authored-by: ivan koryshkin <[email protected]>
Co-authored-by: iwankrshkin <[email protected]>
Co-authored-by: Felipe Imperio <[email protected]>
Co-authored-by: vshvechko <[email protected]>
  • Loading branch information
19 people authored Oct 18, 2024
1 parent 5040f70 commit a74bd23
Show file tree
Hide file tree
Showing 88 changed files with 3,532 additions and 2,131 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code_quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v3
with:
python-version: "3.10"
python-version: "3.11"
- name: Install git-secrets in the repository
run: git secrets --install
- name: Install git-secrets aws register in the repository
Expand Down
25 changes: 21 additions & 4 deletions .github/workflows/run_build_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ on:
# branches:
# - develop
workflow_dispatch: {}
# pull_request:
# types:
# - closed


concurrency:
cancel-in-progress: true
Expand All @@ -26,9 +24,12 @@ env:
BUILD_NAME: ${{github.event_name}}
BUILD_NUMBER: ${{github.run_id}}
ECR_ADDRESS: 917902836630.dkr.ecr.us-east-1.amazonaws.com
DR_ECR_ADDRESS: 973422231492.dkr.ecr.us-west-2.amazonaws.com
OUT_DIR: ./out
AWS_REGION : "us-east-1"
DR_AWS_REGION : "us-west-2"
ECR_REPO: 917902836630.dkr.ecr.us-east-1.amazonaws.com/api-server
DR_ECR_REPO: 973422231492.dkr.ecr.us-west-2.amazonaws.com/api-server


jobs:
Expand All @@ -37,6 +38,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
IMAGE_NAME: ${{ steps.sha.outputs.IMAGE_NAME }}
IMAGE_SHA: ${{ steps.sha.outputs.SHORT_SHA }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -77,6 +79,17 @@ jobs:
run: |
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${{ env.ECR_ADDRESS }}
- name: configure aws DR credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::973422231492:role/cmiml-dr-oidc-github-role
role-session-name: gha-oidc-runner
aws-region: ${{ env.DR_AWS_REGION }}

- name: Login to DR ECR
run: |
aws ecr get-login-password --region ${{ env.DR_AWS_REGION }} | docker login --username AWS --password-stdin ${{ env.DR_ECR_ADDRESS }}
- name: Generate short sha
id: sha
run: |
Expand All @@ -94,7 +107,11 @@ jobs:
PIPENV_EXTRA_ARGS=--dev
cache-to: mode=max,image-manifest=true,oci-mediatypes=true,type=registry,ref=${{ env.ECR_REPO }}:cache
cache-from: type=registry,ref=${{ env.ECR_REPO }}:cache
tags: ${{ steps.sha.outputs.IMAGE_NAME }},${{ env.ECR_REPO }}:latest
tags: |
${{ env.ECR_REPO }}:latest
${{ env.ECR_REPO }}:${{ steps.sha.outputs.SHORT_SHA }}
${{ env.DR_ECR_REPO }}:latest
${{ env.DR_ECR_REPO }}:${{ steps.sha.outputs.SHORT_SHA }}
platforms: linux/amd64,linux/arm64

- name: Upload artifacts
Expand Down
49 changes: 0 additions & 49 deletions .github/workflows/run_deploy_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,55 +24,6 @@ env:
IMAGE_NAME: ${{ inputs.IMAGE_NAME }}

jobs:
# run_migration:
# environment: dev
# name: Run Database Migrations
# runs-on: ubuntu-latest
# env:
# TASK_DEFINITION: migration
# ECS_SERVICE_NAME: migration
#
# steps:
# - name: echo IMAGE_NAME
# run: |
# echo $IMAGE_NAME
#
# - name: configure aws credentials
# uses: aws-actions/configure-aws-credentials@v3
# with:
# role-to-assume: arn:aws:iam::017925157769:role/cmiml-dev-oidc-github-role
# role-session-name: OIDC-GHA-session
# aws-region: ${{ env.AWS_REGION }}
#
# - name: Download task definition
# run: |
# aws ecs describe-task-definition --task-definition ${{ env.TASK_DEFINITION }} --query taskDefinition > task-definition.json
#
# - name: Render Amazon ECS task definition
# id: task-def
# uses: aws-actions/amazon-ecs-render-task-definition@v1
# with:
# task-definition: task-definition.json
# container-name: mind_logger
# image: ${{ inputs.IMAGE_NAME }}
#
# - name: Update Task Definition
# uses: aws-actions/amazon-ecs-deploy-task-definition@v1
# with:
# task-definition: ${{ steps.task-def.outputs.task-definition }}
#
# - name: Run migration container
# id: run-task
# uses: geekcell/github-action-aws-ecs-run-task@v4
# with:
# cluster: ${{ env.ECS_CLUSTER_NAME }}
# task-definition: ${{ env.TASK_DEFINITION }}
# subnet-ids: subnet-02b7cfd48947b31ef
# security-group-ids: sg-0976f7b2b2b5bf411
# override-container-command: |
# /bin/sh
# -c
# /fastapi-migrate all

deploy_to_ecs:
runs-on: ubuntu-latest
Expand Down
74 changes: 33 additions & 41 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,27 @@ verify_ssl = true
name = "pypi"

[packages]
redis = "==5.0.8"
alembic = "==1.13.2"
aio-pika = "==9.4.3"
aiofiles = "==24.1.0"
aiohttp = "==3.10.9"
alembic = "==1.13.3"
asyncpg = "==0.29.0"
azure-storage-blob = "==12.22.0"
bcrypt = "==4.2.0"
boto3 = "==1.35.16"
fastapi = "==0.110.3"
# The latest version of the fastapi is not taken because of the issue
# with fastapi-mail that requires 0.21 < starlette < 0.22
# starlette version for those deps ==0.21.0
# with fastapi-mail that requires 0.21 < starlette < 0.22

fastapi-mail = "==1.2.9"
firebase-admin = "==6.5.0"
httpx = "==0.27.2"
jinja2 = "==3.1.4"
bcrypt = "==4.2.0"
passlib = { version = "==1.7.4", extras = ["bcrypt"] }
pyOpenSSL = "==24.2.1"
pydantic = { extras = ["email"], version = "==1.10.18" }
python-jose = { version = "==3.3.0", extras = ["cryptography"] }
python-multipart = "==0.0.9"
sentry-sdk = "~=2.13"
sqlalchemy = { extras = ["asyncio"], version = "==1.4.53" }
uvicorn = { extras = ["standard"], version = "==0.30.6" }
taskiq = { extras = ["reload"], version = "==0.11.7" }
aiohttp = "==3.10.5"
firebase-admin = "==6.5.0"
aio-pika = "==9.4.3"
azure-storage-blob = "==12.22.0"
taskiq-fastapi = "==0.3.2"
taskiq-redis = "==1.0.0"
taskiq-aio-pika = "==0.4.1"
sqlalchemy-utils = "==0.41.2"
typer = "==0.12.5"
aiofiles = "==24.1.0"
nh3 = "==0.2.18"
opentelemetry-api = "==1.27.0"
opentelemetry-sdk = "==1.27.0"
opentelemetry-exporter-otlp = "==1.27.0"
opentelemetry-distro = "==0.48b0"
opentelemetry-exporter-otlp = "==1.27.0"
opentelemetry-instrumentation = "==0.48b0"
opentelemetry-instrumentation-asgi = "==0.48b0"
opentelemetry-instrumentation-asyncio = "==0.48b0"
Expand All @@ -49,51 +35,57 @@ opentelemetry-instrumentation-sqlite3 = "==0.48b0"
opentelemetry-instrumentation-tortoiseorm = "==0.48b0"
opentelemetry-instrumentation-urllib = "==0.48b0"
opentelemetry-instrumentation-wsgi = "==0.48b0"
opentelemetry-propagator-aws-xray = "==1.0.2"
opentelemetry-sdk = "==1.27.0"
opentelemetry-sdk-extension-aws = "==2.0.2"
opentelemetry-semantic-conventions = "==0.48b0"
opentelemetry-test-utils = "==0.48b0"
opentelemetry-util-http = "==0.48b0"
opentelemetry-propagator-aws-xray = "==1.0.2"
opentelemetry-sdk-extension-aws = "==2.0.2"
nh3 = "==0.2.18"
pyOpenSSL = "==24.2.1"
pydantic = { extras = ["email"], version = "==1.10.18" }
pymongo = "*"
python-multipart = "==0.0.12"
redis = "==5.1.0"
sentry-sdk = "~=2.13"
sqlalchemy = { extras = ["asyncio"], version = "==1.4.53" }
sqlalchemy-utils = "==0.41.2"
taskiq = { extras = ["reload"], version = "==0.11.7" }
taskiq-aio-pika = "==0.4.1"
taskiq-fastapi = "==0.3.2"
taskiq-redis = "==1.0.2"
typer = "==0.12.5"
uvicorn = { extras = ["standard"], version = "==0.30.6" }
pyjwt = "==2.9.0"

[dev-packages]
# Nobody knows for what its needed
ipdb = "==0.13.13"
pudb = "==2024.1.2"
# Linters and Formatters
pre-commit = "==3.8.0"
ruff = "==0.6.4"
# Tests
ruff = "==0.6.8"
allure-pytest = "==2.13.5"
pydantic-factories = "==1.17.3"
pytest = "==8.3.3"
pytest-asyncio = "~=0.19"
pytest-cov = "==5.0.0"
pytest-env = "==1.1.4"
pytest-env = "==1.1.5"
pytest-lazy-fixtures = "==1.1.1"
pytest-mock = "==3.14.0"
nest-asyncio = "==1.6.0"
gevent = "==24.2.1"
# MyPy
mypy = "==1.11.2"
types-passlib = "==1.7.7.20240819"
types-python-dateutil = "==2.9.0.20240906"
types-python-jose = "==3.3.4.20240106"
typing-extensions = "==4.12.2"
types-requests = "==2.32.0.20240712"
types-pytz = "==2024.1.0.20240417"
types-requests = "==2.32.0.20240914"
types-pytz = "==2024.2.0.20240913"
types-aiofiles = "==24.1.0.20240626"
types-cachetools = "==5.5.0.20240820"
# https://github.com/sqlalchemy/sqlalchemy/issues/7714
greenlet = "==3.1.0"
# JSONLD deps only for dev
reproschema = "*"
cachetools = "==5.3.0"
pyld = "==2.0.4"

[requires]
python_version = "3.10"
python_version = "3.11"

[scripts]
cli = "python src/cli.py"
Loading

0 comments on commit a74bd23

Please sign in to comment.