FEATURE: improves staff notes report to support dates
This commit is contained in:
parent
2c730c2136
commit
8b32408a3b
|
@ -1,4 +1,4 @@
|
||||||
{{admin-report
|
{{admin-report
|
||||||
dataSourceName="recent_staff_notes"
|
dataSourceName="staff_notes"
|
||||||
startDate=lastWeek
|
startDate=lastWeek
|
||||||
endDate=endDate}}
|
endDate=endDate}}
|
||||||
|
|
|
@ -46,6 +46,20 @@
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-report.recent-staff-notes {
|
.admin-report.staff-notes {
|
||||||
grid-column: span 12;
|
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}"
|
user_silenced: "@%{username} silenced this account until %{silenced_till}. Reason: %{reason}"
|
||||||
|
|
||||||
reports:
|
reports:
|
||||||
recent_staff_notes:
|
staff_notes:
|
||||||
title: "Recent staff notes"
|
title: "Staff notes"
|
||||||
labels:
|
labels:
|
||||||
user: User
|
user: User
|
||||||
note: Note
|
note: Note
|
||||||
|
|
19
plugin.rb
19
plugin.rb
|
@ -264,27 +264,26 @@ after_initialize do
|
||||||
end
|
end
|
||||||
|
|
||||||
if respond_to? :add_report
|
if respond_to? :add_report
|
||||||
add_report('recent_staff_notes') do |report|
|
add_report('staff_notes') do |report|
|
||||||
report.modes = [:table]
|
report.modes = [:table]
|
||||||
|
|
||||||
report.data = []
|
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 = [
|
report.labels = [
|
||||||
{ type: :link, properties: ["username", "user_url"], title: I18n.t("reports.recent_staff_notes.labels.user") },
|
{ type: :link, properties: ["username", "user_url"], title: I18n.t("reports.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.staff_notes.labels.moderator") },
|
||||||
{ type: :link, properties: ["moderator_username", "moderator_url"], title: I18n.t("reports.recent_staff_notes.labels.moderator") }
|
{ type: :text, properties: ["note"], title: I18n.t("reports.staff_notes.labels.note") }
|
||||||
]
|
]
|
||||||
|
|
||||||
|
values = []
|
||||||
|
report.timeout = wrap_slow_query do
|
||||||
values = PluginStoreRow
|
values = PluginStoreRow
|
||||||
.where(plugin_name: 'staff_notes')
|
.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)
|
.order(id: :desc)
|
||||||
.limit(report.limit || 10)
|
|
||||||
.pluck(:value)
|
.pluck(:value)
|
||||||
|
end
|
||||||
|
|
||||||
values.each do |value|
|
values.each do |value|
|
||||||
data = {}
|
data = {}
|
||||||
|
|
Loading…
Reference in New Issue