FEATURE: improves staff notes report to support dates
This commit is contained in:
parent
2c730c2136
commit
8b32408a3b
|
@ -1,4 +1,4 @@
|
|||
{{admin-report
|
||||
dataSourceName="recent_staff_notes"
|
||||
dataSourceName="staff_notes"
|
||||
startDate=lastWeek
|
||||
endDate=endDate}}
|
||||
|
|
|
@ -46,6 +46,20 @@
|
|||
cursor: pointer;
|
||||
}
|
||||
|
||||
.admin-report.recent-staff-notes {
|
||||
.admin-report.staff-notes {
|
||||
grid-column: span 12;
|
||||
|
||||
.admin-report-table {
|
||||
table-layout: auto;
|
||||
|
||||
tbody tr td,
|
||||
thead tr th {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
thead tr th.note,
|
||||
tbody tr td.note {
|
||||
width: 60%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@ en:
|
|||
user_silenced: "@%{username} silenced this account until %{silenced_till}. Reason: %{reason}"
|
||||
|
||||
reports:
|
||||
recent_staff_notes:
|
||||
title: "Recent staff notes"
|
||||
staff_notes:
|
||||
title: "Staff notes"
|
||||
labels:
|
||||
user: User
|
||||
note: Note
|
||||
|
|
27
plugin.rb
27
plugin.rb
|
@ -264,27 +264,26 @@ after_initialize do
|
|||
end
|
||||
|
||||
if respond_to? :add_report
|
||||
add_report('recent_staff_notes') do |report|
|
||||
add_report('staff_notes') do |report|
|
||||
report.modes = [:table]
|
||||
|
||||
report.data = []
|
||||
|
||||
# TODO
|
||||
# plugin store row doesn’t have created_at
|
||||
# this could be improved by querying on the text field
|
||||
report.dates_filtering = false
|
||||
|
||||
report.labels = [
|
||||
{ type: :link, properties: ["username", "user_url"], title: I18n.t("reports.recent_staff_notes.labels.user") },
|
||||
{ type: :text, properties: ["note"], title: I18n.t("reports.recent_staff_notes.labels.note") },
|
||||
{ type: :link, properties: ["moderator_username", "moderator_url"], title: I18n.t("reports.recent_staff_notes.labels.moderator") }
|
||||
{ type: :link, properties: ["username", "user_url"], title: I18n.t("reports.staff_notes.labels.user") },
|
||||
{ type: :link, properties: ["moderator_username", "moderator_url"], title: I18n.t("reports.staff_notes.labels.moderator") },
|
||||
{ type: :text, properties: ["note"], title: I18n.t("reports.staff_notes.labels.note") }
|
||||
]
|
||||
|
||||
values = PluginStoreRow
|
||||
.where(plugin_name: 'staff_notes')
|
||||
.order(id: :desc)
|
||||
.limit(report.limit || 10)
|
||||
.pluck(:value)
|
||||
values = []
|
||||
report.timeout = wrap_slow_query do
|
||||
values = PluginStoreRow
|
||||
.where(plugin_name: 'staff_notes')
|
||||
.where("value::json->0->>'created_at'>?", report.start_date)
|
||||
.where("value::json->0->>'created_at'<?", report.end_date)
|
||||
.order(id: :desc)
|
||||
.pluck(:value)
|
||||
end
|
||||
|
||||
values.each do |value|
|
||||
data = {}
|
||||
|
|
Loading…
Reference in New Issue