Compare commits

...

5 Commits
1.1.0 ... 1.2.2

Author SHA1 Message Date
renovate[bot]
98df462b61 chore: Configure Renovate (#1)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Conrad <grosserconrad@gmail.com>
2024-11-24 16:05:51 +01:00
6db2b3e14e Update ci.yml 2024-11-24 16:05:40 +01:00
22eaed8a75 fix: fixed an issue with duplicate operation_id 2024-10-10 23:38:35 +02:00
creyD
4d0ecb2ee8 Adjusted files for isort & autopep 2024-10-10 21:35:18 +00:00
88e97faddb feat: added select delete 2024-10-10 23:34:45 +02:00
4 changed files with 68 additions and 4 deletions

View File

@@ -13,6 +13,10 @@ on:
- "**/CHANGELOG.md"
- "**/docs/**"
workflow_dispatch:
pull_request:
branches:
- dev
- master
env:
REGISTRY: ghcr.io

View File

@@ -17,6 +17,8 @@ from uuid import UUID
from pydantic.json_schema import SkipJsonSchema
from fastapi_filters import FilterValues, create_filters
from fastapi_filters.ext.sqlalchemy import apply_filters
from app.models.entry import LogType, TransactionType
from datetime import datetime
router = APIRouter(prefix="/log", tags=["logging"])
@@ -62,10 +64,6 @@ async def get_log(
return LogOUT.model_validate(obj)
from app.models.entry import LogType, TransactionType
from datetime import datetime
@router.get("/")
async def get_logs(
search: str | SkipJsonSchema[None] = None,
@@ -94,3 +92,37 @@ async def get_logs(
LogEntry.message.ilike(f"%{search}%") | LogEntry.author.ilike(f"%{search}%")
)
return paginate(db, order_by_query(the_select))
@router.delete("/", status_code=200, operation_id="log_delete_many")
async def delete_logs(
application: UUID,
environment: str | SkipJsonSchema[None] = None,
l_type: LogType | SkipJsonSchema[None] = None,
t_type: TransactionType | SkipJsonSchema[None] = None,
object_reference: str | SkipJsonSchema[None] = None,
author: str | SkipJsonSchema[None] = None,
sub: str = Security(verify),
db: Session = Depends(get_db),
) -> int:
filters = {
"application": application,
"created_by_id": sub,
}
if environment is not None:
filters["environment"] = environment
if l_type is not None:
filters["l_type"] = l_type
if t_type is not None:
filters["t_type"] = t_type
if object_reference is not None:
filters["object_reference"] = object_reference
if author is not None:
filters["author"] = author
query = db.query(LogEntry).filter_by(**filters)
the_impact = query.count()
query.delete(synchronize_session=False)
db.commit()
return the_impact

View File

@@ -239,3 +239,24 @@ class TestAPI:
re = self.c.get("/log/?application=" + app_id + "&environment=prod")
assert re["total"] == 2
assert len(re["results"]) == 2
def test_logging_delete(self):
with log_examples(self) as app_id:
re = self.c.delete("/log/?application=" + str(app_id) + "&environment=prod", r_code=200)
assert re == 2
re = self.c.get("/log/?application=" + str(app_id) + "&environment=prod")
assert re["total"] == 0
re = self.c.get("/log/?application=" + str(app_id) + "&environment=dev")
assert re["total"] == 3
# clear complete application
re = self.c.get("/log/?application=" + str(app_id))
assert re["total"] == 3
re = self.c.delete("/log/?application=" + str(app_id), r_code=200)
assert re == 3
re = self.c.get("/log/?application=" + str(app_id))
assert re["total"] == 0

7
renovate.json Normal file
View File

@@ -0,0 +1,7 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended",
":semanticCommitTypeAll(feat)"
]
}