Skip to content

Auto report closing doesn't update updated_at #661

@mdashlw

Description

@mdashlw

def close_report_query({reportable_type, reportable_id} = _type_and_id, closing_user) do
from r in Report,
where:
r.reportable_type == ^reportable_type and r.reportable_id == ^reportable_id and
r.open == true,
select: r.id,
update: [set: [open: false, state: "closed", admin_id: ^closing_user.id]]
end
@doc """
Closes all open reports for the given reportable type and ID, marking them as closed by the specified user.
Also reindexes the affected reports.
Returns `{:ok, {count, reports}}`.
"""
def close_reports(type_and_id, closing_user) do
{_count, reports} =
result = Repo.update_all(close_report_query(type_and_id, closing_user), [])
reindex_reports(reports)
{:ok, result}
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions