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
Feature: Improve reports ui #7032
Feature: Improve reports ui #7032
Conversation
I really want to try to get the additional ActionLog items that are relevant into the report, but I'm not sure how to do this. Open to suggestions. |
it would be really good if the moderation log and action log displayed
interleaved with each other I think
…On Tue, Apr 3, 2018, 7:18 PM Emelia Smith ***@***.***> wrote:
I really want to try to get the additional ActionLog items that are
relevant into the report, but I'm not sure how to do this. Open to
suggestions.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#7032 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAORV-HfERQglSDv-pnbf3XxPz_RA4Tzks5tlAMogaJpZM4TF7g_>
.
|
@nightpool oh, I agree, but I've absolutely no idea how to do that in rails. Not to mention that it's not the full action log for now, which I'm struggling to build. |
I'm liking this a lot. 👍 |
app/models/report.rb
Outdated
} | ||
|
||
Admin::ActionLog.from(sql) | ||
end |
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.
This probably isn't ideal or perfect, so I'm open to suggestions here @nightpool @Gargron
Okay, I've added a limit on the report history to be only actions within the timeframe of the report (report.created_at..report.updated_at) and ensure that adding notes updates the report. |
app/models/report.rb
Outdated
).unscope(:order) | ||
|
||
query = "((#{report_log.to_sql}) UNION ALL (#{target_account_log.to_sql}) UNION ALL (#{statuses_log.to_sql})) as admin_action_logs" | ||
sql = Admin::ActionLog.connection.unprepared_statement(query) |
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.
It seems that this method takes a block argument, i.e. unprepared_statement { query }
, but I am not totally sure why unprepared_statement is needed in here?
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.
We may want to just use https://github.com/brianhempel/active_record_union to do this the clean way
@Gargron this is just what I found when looking up how to do union queries with rails; there's probably a better way to do this, though I'm a bit out of my depth with rails knowledge needed.
… On 4 Apr 2018, at 8:06 pm, Eugen Rochko ***@***.***> wrote:
@Gargron commented on this pull request.
In app/models/report.rb <#7032 (comment)>:
> + ).unscope(:order)
+
+ target_account_log = Admin::ActionLog.where(
+ target_type: 'Account',
+ target_id: target_account_id,
+ created_at: created_at..updated_at
+ ).unscope(:order)
+
+ statuses_log = Admin::ActionLog.where(
+ target_type: 'Status',
+ target_id: status_ids,
+ created_at: created_at..updated_at
+ ).unscope(:order)
+
+ query = "((#{report_log.to_sql}) UNION ALL (#{target_account_log.to_sql}) UNION ALL (#{statuses_log.to_sql})) as admin_action_logs"
+ sql = Admin::ActionLog.connection.unprepared_statement(query)
It seems that this method takes a block argument, i.e. unprepared_statement { query }, but I am not totally sure why unprepared_statement is needed in here?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#7032 (review)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAB4a5TZrGjAEY2GFCw7UMB-KrK8WERBks5tlQu1gaJpZM4TF7g_>.
|
Here is a fix for the UNION stuff that works for me: diff --git a/app/models/report.rb b/app/models/report.rb
index e1bfa99..5b90c7b 100644
--- a/app/models/report.rb
+++ b/app/models/report.rb
@@ -61,27 +61,28 @@ class Report < ApplicationRecord
end
def history
- report_log = Admin::ActionLog.where(
- target_type: 'Report',
- target_id: id,
- created_at: created_at..updated_at
- ).unscope(:order)
-
- target_account_log = Admin::ActionLog.where(
- target_type: 'Account',
- target_id: target_account_id,
- created_at: created_at..updated_at
- ).unscope(:order)
-
- statuses_log = Admin::ActionLog.where(
- target_type: 'Status',
- target_id: status_ids,
- created_at: created_at..updated_at
- ).unscope(:order)
-
- query = "((#{report_log.to_sql}) UNION ALL (#{target_account_log.to_sql}) UNION ALL (#{statuses_log.to_sql})) as admin_action_logs"
- sql = Admin::ActionLog.connection.unprepared_statement(query)
-
- Admin::ActionLog.from(sql)
+ time_range = created_at..updated_at
+
+ sql = [
+ Admin::ActionLog.where(
+ target_type: 'Report',
+ target_id: id,
+ created_at: time_range
+ ).unscope(:order),
+
+ Admin::ActionLog.where(
+ target_type: 'Account',
+ target_id: target_account_id,
+ created_at: time_range
+ ).unscope(:order),
+
+ Admin::ActionLog.where(
+ target_type: 'Status',
+ target_id: status_ids,
+ created_at: time_range
+ ).unscope(:order),
+ ].map { |query| "(#{query.to_sql})" }.join(' UNION ALL ')
+
+ Admin::ActionLog.from("(#{sql}) AS admin_action_logs")
end
end |
- Clean up notes display - Clean up add new note form - Simplify controller - Allow reopening a report with a note - Show created at date for reports - Fix report details table formatting
…g created and the report being resolved
Thanks @Gargron for the improvements
a691e61
to
dab21f1
Compare
@Gargron this is now ready for review again, the 1 issue to fix from code climate isn't an issue, because we know what we're doing™ |
* Update Japanese translations. * Update Japanese translations. * Update Japanese translations. * Update Japanese translations. * Add Japanese translations for #6984, #7040, #7072. Update Japanese translations for privacy policy. * Add Japanese translations for #7032, #7074, #7089. * Proofreading Japanese translations for privacy policy.
* i18n: (zh-CN) #7532 * i18n: (zh-CN) #6984 * i18n: (zh-CN) #7391, #7507 * i18n: (zh-CN) #6998 * i18n: (zh-CN) #7074 * i18n: (zh-CN) #7000, #7032, #7131 (#7032, #7040) * i18n: (zh-CN) #7130, #7188 * i18n: (zh-CN) #6486 * i18n: (zh-CN) #6292 * i18n: (zh-CN) #7347 * i18n: (zh-CN) #6661 * i18n: (zh-CN) #6425 * i18n: (zh-CN) #6597 * i18n: (zh-CN) #6695 * i18n: (zh-CN) #6325 * i18n: (zh-CN) #6460, #7375 * i18n: (zh-CN) #6872 * i18n: (zh-CN) #6818 * i18n: (zh-CN) #7452 * i18n: (zh-CN) #7176 * i18n: (zh-CN) #6460 * i18n: (zh-CN) #7213 * i18n: (zh-CN) #7376 * i18n: (zh-CN) #6556 * i18n: (zh-CN) #6645 * i18n: (zh-CN) #6448 * i18n: (zh-CN) #5303 * i18n: (zh-CN) #7445 * i18n: (zh-CN) Normalization and improvements * i18n: (zh-CN) #7391 * i18n: (zh-CN) #6627 * i18n: (zh-CN) #6956, #7546 * i18n: (zh-CN) #6636 * i18n: (zh-CN) #6610, #6875 * i18n: (zh-CN) #6887 * i18n: (zh-CN) #4514 * i18n: (zh-CN) #6628 * i18n: (zh-CN) #6771 * i18n: (zh-CN) #6772 * i18n: (zh-CN) #7178 * i18n: (zh-CN) #7521 * i18n: (zh-CN) #6570 * i18n: (zh-CN) #6593 * i18n: (zh-CN) #6423 * i18n: (zh-CN) #6157 * i18n: (zh-CN) #7089 * i18n: (zh-CN) #6733 * i18n: (zh-CN) #7072 * i18n: (zh-CN) #6520 * i18n: (zh-CN) Improvment * i18n: (zh-CN) #6631
* Further improvements to Reports UI - Clean up notes display - Clean up add new note form - Simplify controller - Allow reopening a report with a note - Show created at date for reports - Fix report details table formatting * Show history of report using Admin::ActionLog beneath the report * Fix incorrect log message when reopening a report * Implement fetching of all ActionLog items that could be related to the report * Ensure adding a report_note updates the report's updated_at * Limit Report History to actions that happened between the report being created and the report being resolved * Fix linting issues * Improve report history builder Thanks @Gargron for the improvements
After playing with the improved reports UI from #7000, I still wasn't happy with it. I've since redesigned the form for adding report notes, and added the "ActionLog" history (in a rough form) so we can see all the actions taken in relation to a specific report.
Note: I wasn't sure on the right way to implement fetching the ActionLog, so went with a relation, but now I think a Finder method would be better, as it needs to pull from the Report, the statuses of the report and the reported user; Though I'm not sure on the best way to implement this.
Here's what the page now looks like: