FEATURE: improves staff notes report to support dates

This commit is contained in:
Joffrey JAFFEUX 2018-07-19 21:51:11 -04:00
parent 2c730c2136
commit 8b32408a3b
4 changed files with 31 additions and 18 deletions

View File

@ -1,4 +1,4 @@
{{admin-report {{admin-report
dataSourceName="recent_staff_notes" dataSourceName="staff_notes"
startDate=lastWeek startDate=lastWeek
endDate=endDate}} endDate=endDate}}

View File

@ -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%;
}
}
} }

View File

@ -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

View File

@ -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 doesnt 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 = PluginStoreRow values = []
.where(plugin_name: 'staff_notes') report.timeout = wrap_slow_query do
.order(id: :desc) values = PluginStoreRow
.limit(report.limit || 10) .where(plugin_name: 'staff_notes')
.pluck(:value) .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| values.each do |value|
data = {} data = {}