FEATURE: support filter options for PM report

This commit is contained in:
Arpit Jalan 2016-04-21 14:52:41 +05:30
parent 89a7a90208
commit ee7ef46b9e
4 changed files with 11 additions and 11 deletions

View File

@ -27,7 +27,7 @@ export default Ember.Controller.extend({
},
@computed('model.type')
showFilterOptions(modelType) {
showCategoryOptions(modelType) {
return !modelType.match(/_private_messages$/);
},

View File

@ -1,15 +1,15 @@
<h3>{{model.title}}</h3>
<div class="admin-reports-filter">
{{#if showFilterOptions}}
{{i18n 'admin.dashboard.reports.start_date'}} {{date-picker-past value=startDate}}
{{i18n 'admin.dashboard.reports.end_date'}} {{date-picker-past value=endDate}}
{{i18n 'admin.dashboard.reports.start_date'}} {{date-picker-past value=startDate}}
{{i18n 'admin.dashboard.reports.end_date'}} {{date-picker-past value=endDate}}
{{#if showCategoryOptions}}
{{combo-box valueAttribute="value" content=categoryOptions value=categoryId}}
{{#if showGroupOptions}}
{{combo-box valueAttribute="value" content=groupOptions value=groupId}}
{{/if}}
{{d-button action="refreshReport" class="btn-primary" label="admin.dashboard.reports.refresh_report" icon="refresh"}}
{{/if}}
{{#if showGroupOptions}}
{{combo-box valueAttribute="value" content=groupOptions value=groupId}}
{{/if}}
{{d-button action="refreshReport" class="btn-primary" label="admin.dashboard.reports.refresh_report" icon="refresh"}}
{{d-button action="exportCsv" label="admin.export_csv.button_text" icon="download"}}
</div>

View File

@ -557,8 +557,8 @@ class Post < ActiveRecord::Base
result.group('date(posts.created_at)').order('date(posts.created_at)').count
end
def self.private_messages_count_per_day(since_days_ago, topic_subtype)
private_posts.with_topic_subtype(topic_subtype).where('posts.created_at > ?', since_days_ago.days.ago).group('date(posts.created_at)').order('date(posts.created_at)').count
def self.private_messages_count_per_day(start_date, end_date, topic_subtype)
private_posts.with_topic_subtype(topic_subtype).where('posts.created_at >= ? AND posts.created_at <= ?', start_date, end_date).group('date(posts.created_at)').order('date(posts.created_at)').count
end
def reply_history(max_replies=100, guardian=nil)

View File

@ -205,7 +205,7 @@ class Report
# Private messages counts:
def self.private_messages_report(report, topic_subtype)
basic_report_about report, Post, :private_messages_count_per_day, default_days, topic_subtype
basic_report_about report, Post, :private_messages_count_per_day, report.start_date, report.end_date, topic_subtype
add_counts report, Post.private_posts.with_topic_subtype(topic_subtype), 'posts.created_at'
end