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

Add content tag models #215

Merged
merged 99 commits into from
May 30, 2024
Merged

Add content tag models #215

merged 99 commits into from
May 30, 2024

Conversation

lickem22
Copy link
Contributor

@lickem22 lickem22 commented May 17, 2024

Reviewer: @amiraliemami
Estimate: 1h


Ticket

Fixes: AAQ-523

Description

Goal

The goal is to add implement adding tags to contents

Changes

On backend:

  • Updated DB to add tags
  • Added tags submodules as well as tests
  • Updated contents to have tags
  • Updated contents tags

Future Tasks (optional)

  • Add a button to add tags on the go

How has this been tested?

Tests have been implemented and run. Frontend has been tested as well.

Checklist

Fill with x for completed. Delete any lines that are not relevant

  • My code follows the style guidelines of this project
  • I have reviewed my own code to ensure good quality
  • I have tested the functionality of my code to ensure it works as intended
  • I have resolved merge conflicts
  • I have updated the automated tests (if applicable)
  • I have updated the requirements (if applicable)
  • I have updated the README file (if applicable)
  • I have updated affected documentation (if applicable)
  • I have added blogpost in Latest Updates

…ser_id hardcoded into QA and WhatsApp endpoints - to be inferred from bearer token later.
suzinyou and others added 8 commits May 16, 2024 18:49
* Add key management endpoint pytest

* TEMP: Add test for user functions (not working due to async issue)

* fix scope of asession in test_urgency_detect (future-proofing)

* Fix user tests with async session

* Add where to set/find login credentials to docs

* Temporary fix for rotation endpoint test

* Fix scope mismatch (some UD tests break)

* Add multi-user tests for content CRUD

* Add multi-user tests for UD CRUD + add fetch check first in delete endpoint

* Add user2 token denial test to retrieval and UD detect

* Put multi-user tests under a different class

* fixed async tests in session scope issue

* Make test user_ids integers to match new schema

* Fix handling of user_ids in pytest

* Separate content CRUD multi-user tests and use fixture

* Separate UD CRUD multi-user tests and use fixture

---------

Co-authored-by: Sid Ravinutala <[email protected]>
* Add key management endpoint pytest

* TEMP: Add test for user functions (not working due to async issue)

* fix scope of asession in test_urgency_detect (future-proofing)

* Fix user tests with async session

* Add where to set/find login credentials to docs

* Temporary fix for rotation endpoint test

* Fix scope mismatch (some UD tests break)

* Add multi-user tests for content CRUD

* Add multi-user tests for UD CRUD + add fetch check first in delete endpoint

* Add user2 token denial test to retrieval and UD detect

* Put multi-user tests under a different class

* fixed async tests in session scope issue

* Make test user_ids integers to match new schema

* Fix handling of user_ids in pytest

* Separate content CRUD multi-user tests and use fixture

* Separate UD CRUD multi-user tests and use fixture

* Playground: Add type of search to user message display

* Make dashboard functions filter on user_id

* Playground: change "JSON" to "<json>" in error message response.

* UD page: Make background white for now

* move key_management tests to run last :)

* Remove incorrect retrieval tests

* improve query type formatting and use save button for ud rule

---------

Co-authored-by: Sid Ravinutala <[email protected]>
Co-authored-by: Suzin You <[email protected]>
@lickem22 lickem22 changed the base branch from multitenancy/feature to main May 17, 2024 10:26
Copy link

infracost bot commented May 28, 2024

💰 Infracost report

Monthly cost will decrease by $0.40 📉

Changed project Baseline cost Usage cost* Total change New monthly cost
deployment-aws-infrastructure-testing-testing -$0.40 +$0 -$0.40 (0%) $105

*Usage costs can be estimated by updating Infracost Cloud settings, see docs for other options.

Cost details (includes details of unsupported resources)
Key: * usage cost, ~ changed, + added, - removed

──────────────────────────────────
Project: deployment-aws-infrastructure-testing-testing
Module path: deployment/aws/infrastructure/testing

+ module.main.aws_secretsmanager_secret.user_credentials_secret
  +$0.40

    + Secret
      +$0.40

    + API requests
      Monthly cost depends on usage
        +$0.05 per 10k requests

- module.main.aws_secretsmanager_secret.content_access_secret
  -$0.40

    - Secret
      -$0.40

    - API requests
      Monthly cost depends on usage
        -$0.05 per 10k requests

- module.main.aws_secretsmanager_secret.question_answer_secret
  -$0.40

    - Secret
      -$0.40

    - API requests
      Monthly cost depends on usage
        -$0.05 per 10k requests

Monthly cost change for deployment-aws-infrastructure-testing-testing (Module path: deployment/aws/infrastructure/testing)
Amount:  -$0.40 ($105 → $105)
Percent: 0%

──────────────────────────────────
Key: * usage cost, ~ changed, + added, - removed
2 projects have no cost estimate changes.
Run the following command to see their breakdown: infracost breakdown --path=/path/to/code

──────────────────────────────────
*Usage costs can be estimated by updating Infracost Cloud settings, see docs for other options.

184 cloud resources were detected:
∙ 39 were estimated
∙ 141 were free
∙ 4 are not supported yet, see https://infracost.io/requested-resources:
  ∙ 2 x aws_service_discovery_private_dns_namespace
  ∙ 2 x aws_vpc_endpoint_policy

Infracost estimate: Monthly cost will decrease by $0.40 ↓
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
┃ Changed project                                    ┃ Baseline cost ┃ Usage cost ┃ Total change ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━╋━━━━━━━━━━━━╋━━━━━━━━━━━━━━┫
┃ deployment-aws-infrastructure-testing-testing      ┃        -$0.40 ┃        +$0 ┃  -$0.40 (0%) ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━┻━━━━━━━━━━━━┻━━━━━━━━━━━━━━┛
This comment will be updated when code changes.

docs/develop/setup.md Outdated Show resolved Hide resolved
@lickem22 lickem22 marked this pull request as ready for review May 28, 2024 12:19
Copy link
Collaborator

@amiraliemami amiraliemami left a comment

Choose a reason for hiding this comment

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

Works great, thanks for lots of great thoughtful code! Left a few comments that should be easy to address. Will quickly approve once you've considered them! Mainly preventing the user from adding/editing tags to have the same name

admin_app/src/utils/api.ts Outdated Show resolved Hide resolved
admin_app/src/app/content/edit/page.tsx Outdated Show resolved Hide resolved
Comment on lines 222 to 240
<Layout.Spacer multiplier={2} />
<Autocomplete
multiple
limitTags={3}
id="tags-autocomplete"
options={availableTags}
getOptionLabel={(option) => option!.tag_name}
value={contentTags}
onChange={handleTagsChange}
renderInput={(params) => (
<TextField
{...params}
variant="outlined"
label="Tags"
placeholder="Add Tags"
/>
)}
sx={{ width: "500px" }}
/>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we move this to above the content box as per the figma design? So put it inside AddEditContentPage below the Header component.

Copy link
Contributor Author

@lickem22 lickem22 May 29, 2024

Choose a reason for hiding this comment

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

Actually, I am open to put the tags on top of the Language Bar, but I will keep it within the ContentBox, to make it easier to update content_tags within contents

core_backend/app/tags/config.py Show resolved Hide resolved
core_backend/tests/api/test_manage_tags.py Show resolved Hide resolved
core_backend/app/tags/models.py Outdated Show resolved Hide resolved
user_db.user_id, content.content_tags, asession
)
if not is_tag_valid:
raise HTTPException(status_code=400, detail=f"Invalid tags id: {content_tags}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

/nit does this work for many tags at once? then we should say "Invalid tag ids: " instead of tags id. Same with the next one

core_backend/app/contents/models.py Outdated Show resolved Hide resolved
core_backend/app/contents/models.py Show resolved Hide resolved
core_backend/app/tags/models.py Show resolved Hide resolved
Copy link
Collaborator

@amiraliemami amiraliemami left a comment

Choose a reason for hiding this comment

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

Works great, thanks for the changes!

Only thing I just noticed - the content tags table is called content_tags whereas the new standard we're following would be content-tags. Could you change this before merging? Thanks :)

Ideally all table names would be singular (so content-tag) but I can see how that could get confusing in the code so happy to keep it as tags if that makes more sense.

@lickem22 lickem22 merged commit e341962 into main May 30, 2024
3 checks passed
@suzinyou suzinyou deleted the implement-tags branch June 19, 2024 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants