-
Notifications
You must be signed in to change notification settings - Fork 4
802 add support for automatic foulborn unique tracking #803
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
Draft
Ivareh
wants to merge
18
commits into
main
Choose a base branch
from
802-add-support-for-automatic-foulborn-unique-tracking
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
617fd38
#802 added foulborn unique detector
Ivareh 40ddea0
#802 added empty name filter
Ivareh 0cfd2e3
#802 Created carantene modifier models and schemas in api
Ivareh d9d7d72
#802 Fix new deposit data modifiers and base types
Ivareh 682f318
#802 New carantene mod schemas and endpoints for handling it in api
Ivareh 687047a
#802 Carantene modifier implementation in data retrieval
Ivareh d6e817d
#802 updated grafana schemas
Ivareh 9a3c3c8
#802 Belts and quivers base types
Ivareh 64909fe
#802 Carantene modifier processor
Ivareh 937120a
#802 int fix, timestamp filter for textroll and tuning
Ivareh 2ada75d
#802 grafana remove auth and new dashboard
Ivareh 83e88f3
#802 new base types
Ivareh 6df4a25
#802 carantene modifier init logic
Ivareh b7ce371
#802 init logic in backend data retrieval for carantene mods
Ivareh 7dbe08d
#802 docker env vars and grafana login remove
Ivareh 89e62e8
#802 fixed more base types
Ivareh 4697401
#802 added bulk delete api duplicates
Ivareh 9be1053
#802 deleted duped grouped car mods in retrieval
Ivareh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
src/backend_api/app/alembic/versions/d789cc84cb4d_created_carantene_modifier_table.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| """Created carantene modifier table | ||
|
|
||
| Revision ID: d789cc84cb4d | ||
| Revises: e38727349f3f | ||
| Create Date: 2025-11-18 19:44:38.570115 | ||
|
|
||
| """ | ||
| from typing import Sequence, Union | ||
|
|
||
| from alembic import op | ||
| import sqlalchemy as sa | ||
|
|
||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision: str = 'd789cc84cb4d' | ||
| down_revision: Union[str, None] = 'e38727349f3f' | ||
| branch_labels: Union[str, Sequence[str], None] = None | ||
| depends_on: Union[str, Sequence[str], None] = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.create_table('carantene_modifier', | ||
| sa.Column('caranteneModifierId', sa.BigInteger(), sa.Identity(always=False, start=1, increment=1, cycle=True), nullable=False), | ||
| sa.Column('effect', sa.Text(), nullable=False), | ||
| sa.Column('relatedUnique', sa.Text(), nullable=False), | ||
| sa.Column('implicit', sa.Boolean(), nullable=True), | ||
| sa.Column('explicit', sa.Boolean(), nullable=True), | ||
| sa.Column('delve', sa.Boolean(), nullable=True), | ||
| sa.Column('fractured', sa.Boolean(), nullable=True), | ||
| sa.Column('synthesised', sa.Boolean(), nullable=True), | ||
| sa.Column('unique', sa.Boolean(), nullable=True), | ||
| sa.Column('corrupted', sa.Boolean(), nullable=True), | ||
| sa.Column('enchanted', sa.Boolean(), nullable=True), | ||
| sa.Column('veiled', sa.Boolean(), nullable=True), | ||
| sa.Column('mutated', sa.Boolean(), nullable=True), | ||
| sa.Column('createdAt', sa.DateTime(timezone=True), nullable=False), | ||
| sa.Column('updatedAt', sa.DateTime(timezone=True), nullable=True), | ||
| sa.PrimaryKeyConstraint('caranteneModifierId') | ||
| ) | ||
| op.alter_column('item', 'itemId', | ||
| existing_type=sa.BIGINT(), | ||
| server_default=sa.Identity(always=True, start=1, increment=1), | ||
| existing_nullable=False, | ||
| autoincrement=True) | ||
| # ### end Alembic commands ### | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.alter_column('item', 'itemId', | ||
| existing_type=sa.BIGINT(), | ||
| server_default=sa.Identity(always=False, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1), | ||
| existing_nullable=False, | ||
| autoincrement=True) | ||
| op.drop_table('carantene_modifier') | ||
| # ### end Alembic commands ### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,227 @@ | ||
| from typing import Annotated | ||
|
|
||
| from fastapi import APIRouter, Depends, Query, Request, Response | ||
| from sqlalchemy import text | ||
| from sqlalchemy.orm import Session | ||
|
|
||
| import app.core.schemas as schemas | ||
| from app.api.api_message_util import ( | ||
| get_delete_return_msg, | ||
| ) | ||
| from app.api.deps import ( | ||
| get_current_active_superuser, | ||
| get_current_active_user, | ||
| get_db, | ||
| ) | ||
| from app.api.params import FilterParams | ||
| from app.core.models.models import CaranteneModifier | ||
| from app.core.rate_limit.rate_limit_config import rate_limit_settings | ||
| from app.core.rate_limit.rate_limiters import ( | ||
| apply_user_rate_limits, | ||
| ) | ||
| from app.crud import CRUD_carantene_modifier | ||
|
|
||
| router = APIRouter() | ||
|
|
||
|
|
||
| carantene_modifier_prefix = "carantene_modifier" | ||
|
|
||
|
|
||
| @router.get( | ||
| "/{caranteneModifierId}", | ||
| response_model=schemas.CaranteneModifier | list[schemas.CaranteneModifier], | ||
| dependencies=[Depends(get_current_active_user)], | ||
| ) | ||
| @apply_user_rate_limits( | ||
| rate_limit_settings.DEFAULT_USER_RATE_LIMIT_SECOND, | ||
| rate_limit_settings.DEFAULT_USER_RATE_LIMIT_MINUTE, | ||
| rate_limit_settings.DEFAULT_USER_RATE_LIMIT_HOUR, | ||
| rate_limit_settings.DEFAULT_USER_RATE_LIMIT_DAY, | ||
| ) | ||
| async def get_carantene_modifier( | ||
| request: Request, # noqa: ARG001 | ||
| response: Response, # noqa: ARG001 | ||
| caranteneModifierId: int, | ||
| db: Session = Depends(get_db), | ||
| ): | ||
| """ | ||
| Get carantene modifier or list of carantene modifiers by key and | ||
| value for "caranteneModifierId" | ||
|
|
||
| Returns one or a list of carantene_modifiers. | ||
| """ | ||
|
|
||
| carantene_modifier_map = {"caranteneModifierId": caranteneModifierId} | ||
| carantene_modifier = await CRUD_carantene_modifier.get( | ||
| db=db, filter=carantene_modifier_map | ||
| ) | ||
|
|
||
| return carantene_modifier | ||
|
|
||
|
|
||
| @router.get( | ||
| "/", | ||
| response_model=schemas.CaranteneModifier | list[schemas.CaranteneModifier], | ||
| dependencies=[Depends(get_current_active_user)], | ||
| ) | ||
| @apply_user_rate_limits( | ||
| rate_limit_settings.DEFAULT_USER_RATE_LIMIT_SECOND, | ||
| rate_limit_settings.DEFAULT_USER_RATE_LIMIT_MINUTE, | ||
| rate_limit_settings.DEFAULT_USER_RATE_LIMIT_HOUR, | ||
| rate_limit_settings.DEFAULT_USER_RATE_LIMIT_DAY, | ||
| ) | ||
| async def get_all_carantene_modifiers( | ||
| request: Request, # noqa: ARG001 | ||
| response: Response, # noqa: ARG001 | ||
| filter_params: Annotated[FilterParams, Query()], | ||
| db: Session = Depends(get_db), | ||
| ): | ||
| """ | ||
| Get all carantene_modifiers. | ||
|
|
||
| Returns a list of all carantene_modifiers. | ||
| """ | ||
|
|
||
| all_carantene_modifiers = await CRUD_carantene_modifier.get( | ||
| db=db, filter_params=filter_params | ||
| ) | ||
|
|
||
| return all_carantene_modifiers | ||
|
|
||
|
|
||
| @router.post( | ||
| "/", | ||
| response_model=schemas.CaranteneModifierCreate | ||
| | list[schemas.CaranteneModifierCreate] | ||
| | None, | ||
| dependencies=[Depends(get_current_active_superuser)], | ||
| ) | ||
| async def create_carantene_modifier( | ||
| carantene_modifier: schemas.CaranteneModifierCreate | ||
| | list[schemas.CaranteneModifierCreate], | ||
| return_nothing: bool | None = None, | ||
| db: Session = Depends(get_db), | ||
| ): | ||
| """ | ||
| Create one or a list of new carantene_modifiers. | ||
|
|
||
| Returns the created carantene_modifier or list of carantene_modifiers. | ||
| """ | ||
|
|
||
| return await CRUD_carantene_modifier.create( | ||
| db=db, obj_in=carantene_modifier, return_nothing=return_nothing | ||
| ) | ||
|
|
||
|
|
||
| @router.put( | ||
| "/", | ||
| response_model=schemas.CaranteneModifier, | ||
| dependencies=[Depends(get_current_active_superuser)], | ||
| ) | ||
| async def update_carantene_modifier( | ||
| caranteneModifierId: int, | ||
| carantene_modifier_update: schemas.CaranteneModifierUpdate, | ||
| db: Session = Depends(get_db), | ||
| ): | ||
| """ | ||
| Update a carantene_modifier by key and value for "caranteneModifierId" | ||
|
|
||
| Dominant key is "caranteneModifierId". | ||
|
|
||
| Returns the updated carantene modifier. | ||
| """ | ||
|
|
||
| carantene_modifier_map = {"caranteneModifierId": caranteneModifierId} | ||
|
|
||
| carantene_modifier = await CRUD_carantene_modifier.get( | ||
| db=db, | ||
| filter=carantene_modifier_map, | ||
| ) | ||
|
|
||
| return await CRUD_carantene_modifier.update( | ||
| db_obj=carantene_modifier, obj_in=carantene_modifier_update, db=db | ||
| ) | ||
|
|
||
|
|
||
| @router.delete( | ||
| "/{caranteneModifierId}", | ||
| response_model=str, | ||
| dependencies=[Depends(get_current_active_superuser)], | ||
| ) | ||
| async def delete_carantene_modifier( | ||
| caranteneModifierId: int, | ||
| db: Session = Depends(get_db), | ||
| ): | ||
| """ | ||
| Delete a carantene modifier by key and value for "caranteneModifierId" | ||
|
|
||
| Returns a message that the carantene modifier was deleted. | ||
| Always deletes one carantene_modifier. | ||
| """ | ||
|
|
||
| carantene_modifier_map = {"caranteneModifierId": caranteneModifierId} | ||
| await CRUD_carantene_modifier.remove(db=db, filter=carantene_modifier_map) | ||
|
|
||
| return get_delete_return_msg( | ||
| model_table_name=CaranteneModifier.__tablename__, filter=carantene_modifier_map | ||
| ).message | ||
|
|
||
|
|
||
| @router.delete( | ||
| "/bulk-delete/", | ||
| response_model=str, | ||
| dependencies=[Depends(get_current_active_superuser)], | ||
| ) | ||
| async def bulk_delete_carantene_modifier( | ||
| caranteneModifierIds: list[schemas.CaranteneModifiersPK], | ||
| db: Session = Depends(get_db), | ||
| ): | ||
| """ | ||
| Delete a carantene modifier by key and value for "caranteneModifierId" | ||
|
|
||
| Returns a message that the carantene modifier was deleted. | ||
| Always deletes one carantene_modifier. | ||
| """ | ||
|
|
||
| filter = [car_id.caranteneModifierId for car_id in caranteneModifierIds] | ||
| await CRUD_carantene_modifier.remove( | ||
| db=db, filter=filter, deletion_key="caranteneModifierId" | ||
| ) | ||
|
|
||
| return get_delete_return_msg( | ||
| model_table_name=CaranteneModifier.__tablename__, filter=filter | ||
| ).message | ||
|
|
||
|
|
||
| @router.post( | ||
| "/delete-grouped-dupes/", | ||
| response_model=str, | ||
| dependencies=[Depends(get_current_active_superuser)], | ||
| ) | ||
| async def delete_grouped_dupes_carantene_modifier( | ||
| db: Session = Depends(get_db), | ||
| ): | ||
| group_amount = 12 | ||
|
|
||
| db.execute( | ||
| text( | ||
| f""" | ||
| DELETE FROM "carantene_modifier" | ||
| WHERE "caranteneModifierId" IN ( | ||
| SELECT "caranteneModifierId" | ||
| FROM ( | ||
| SELECT | ||
| "caranteneModifierId", | ||
| ROW_NUMBER() OVER ( | ||
| PARTITION BY "effect" | ||
| ORDER BY "createdAt" DESC | ||
| ) AS rn | ||
| FROM "carantene_modifier" | ||
| ) AS ranked | ||
| WHERE rn > {group_amount} | ||
| ) | ||
| """ | ||
| ) | ||
| ) | ||
|
|
||
| return "Successfully deleted duplicate carantene modifier groups by effect" | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete not post