Skip to content

Two definitions of get_incident_by_id in the same file #1561

@frwl404

Description

@frwl404

Describe the bug
In the file https://github.com/keephq/keep/blob/main/keep/api/core/db.py we have 2 definitions of the same function:

def get_incident_by_id(incident_id: UUID) -> Incident:
    with Session(engine) as session:
        incident = session.exec(
            select(Incident)
            .options(selectinload(Incident.alerts))
            .where(Incident.id == incident_id)
        ).first()
    return incident
def get_incident_by_id(tenant_id: str, incident_id: str) -> Optional[Incident]:
    with Session(engine) as session:
        query = session.query(
            Incident,
        ).filter(
            Incident.tenant_id == tenant_id,
            Incident.id == incident_id,
        )

    return query.first()

First of them is not used (and can't be used) by any other code and I guess could/should be removed

To Reproduce
Observe it in https://github.com/keephq/keep/blob/main/keep/api/core/db.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions