Skip to content

Commit

Permalink
Use activerecord way of determining existing report
Browse files Browse the repository at this point in the history
  • Loading branch information
hellcp-work committed Sep 21, 2023
1 parent 7e5b381 commit b6caa48
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/api/app/components/reports_notice_component.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.text-warning
%i.fas.fa-flag
- if by_user
- if by_user?
You reported this #{reportable.class.name.downcase}.
- else
This #{reportable.class.name.downcase} has #{pluralize(reports.count, 'report')}.
4 changes: 2 additions & 2 deletions src/api/app/components/reports_notice_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ def initialize(reportable:, user:)
@user = user
end

def by_user
!!Report.find_by(user:, reportable:)
def by_user?
Report.exists?(user:, reportable:)
end

def reports
Expand Down

0 comments on commit b6caa48

Please sign in to comment.