Add Posts Read + Visits to User Directory
This commit is contained in:
parent
66bda5267c
commit
1e3e4135a3
|
@ -4,8 +4,14 @@ import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||||
export default Ember.Component.extend(StringBuffer, {
|
export default Ember.Component.extend(StringBuffer, {
|
||||||
tagName: 'th',
|
tagName: 'th',
|
||||||
classNames: ['sortable'],
|
classNames: ['sortable'],
|
||||||
|
attributeBindings: ['title'],
|
||||||
rerenderTriggers: ['order', 'asc'],
|
rerenderTriggers: ['order', 'asc'],
|
||||||
|
|
||||||
|
title: function() {
|
||||||
|
const labelKey = 'directory.' + this.get('field');
|
||||||
|
return I18n.t(labelKey + '_long', { defaultValue: I18n.t(labelKey) });
|
||||||
|
}.property('field'),
|
||||||
|
|
||||||
renderString(buffer) {
|
renderString(buffer) {
|
||||||
|
|
||||||
const icon = this.get('icon');
|
const icon = this.get('icon');
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
{{directory-toggle field="topic_count" order=order asc=asc}}
|
{{directory-toggle field="topic_count" order=order asc=asc}}
|
||||||
{{directory-toggle field="post_count" order=order asc=asc}}
|
{{directory-toggle field="post_count" order=order asc=asc}}
|
||||||
{{directory-toggle field="topics_entered" order=order asc=asc}}
|
{{directory-toggle field="topics_entered" order=order asc=asc}}
|
||||||
|
{{directory-toggle field="posts_read" order=order asc=asc}}
|
||||||
|
{{directory-toggle field="days_visited" order=order asc=asc}}
|
||||||
{{#if showTimeRead}}
|
{{#if showTimeRead}}
|
||||||
<th>{{i18n "directory.time_read"}}</th>
|
<th>{{i18n "directory.time_read"}}</th>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -31,6 +33,8 @@
|
||||||
<td>{{number item.model.topic_count}}</td>
|
<td>{{number item.model.topic_count}}</td>
|
||||||
<td>{{number item.model.post_count}}</td>
|
<td>{{number item.model.post_count}}</td>
|
||||||
<td>{{number item.model.topics_entered}}</td>
|
<td>{{number item.model.topics_entered}}</td>
|
||||||
|
<td>{{number item.model.posts_read}}</td>
|
||||||
|
<td>{{number item.model.days_visited}}</td>
|
||||||
{{#if showTimeRead}}
|
{{#if showTimeRead}}
|
||||||
<td><span class='time-read'>{{unbound item.model.time_read}}</span></td>
|
<td><span class='time-read'>{{unbound item.model.time_read}}</span></td>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -7,7 +7,9 @@ class DirectoryItem < ActiveRecord::Base
|
||||||
:likes_given,
|
:likes_given,
|
||||||
:topics_entered,
|
:topics_entered,
|
||||||
:topic_count,
|
:topic_count,
|
||||||
:post_count]
|
:post_count,
|
||||||
|
:posts_read,
|
||||||
|
:days_visited]
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.period_types
|
def self.period_types
|
||||||
|
@ -31,13 +33,15 @@ class DirectoryItem < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
exec_sql "INSERT INTO directory_items
|
exec_sql "INSERT INTO directory_items
|
||||||
(period_type, user_id, likes_received, likes_given, topics_entered, topic_count, post_count)
|
(period_type, user_id, likes_received, likes_given, topics_entered, days_visited, posts_read, topic_count, post_count)
|
||||||
SELECT
|
SELECT
|
||||||
:period_type,
|
:period_type,
|
||||||
u.id,
|
u.id,
|
||||||
SUM(CASE WHEN ua.action_type = :was_liked_type THEN 1 ELSE 0 END),
|
SUM(CASE WHEN ua.action_type = :was_liked_type THEN 1 ELSE 0 END),
|
||||||
SUM(CASE WHEN ua.action_type = :like_type THEN 1 ELSE 0 END),
|
SUM(CASE WHEN ua.action_type = :like_type THEN 1 ELSE 0 END),
|
||||||
(SELECT COUNT(topic_id) FROM topic_views AS v WHERE v.user_id = u.id AND v.viewed_at > :since),
|
COALESCE((SELECT COUNT(topic_id) FROM topic_views AS v WHERE v.user_id = u.id AND v.viewed_at >= :since), 0),
|
||||||
|
COALESCE((SELECT COUNT(id) FROM user_visits AS uv WHERE uv.user_id = u.id AND uv.visited_at >= :since), 0),
|
||||||
|
COALESCE((SELECT SUM(posts_read) FROM user_visits AS uv2 WHERE uv2.user_id = u.id AND uv2.visited_at >= :since), 0),
|
||||||
SUM(CASE WHEN ua.action_type = :new_topic_type THEN 1 ELSE 0 END),
|
SUM(CASE WHEN ua.action_type = :new_topic_type THEN 1 ELSE 0 END),
|
||||||
SUM(CASE WHEN ua.action_type = :reply_type THEN 1 ELSE 0 END)
|
SUM(CASE WHEN ua.action_type = :reply_type THEN 1 ELSE 0 END)
|
||||||
FROM users AS u
|
FROM users AS u
|
||||||
|
|
|
@ -242,11 +242,18 @@ en:
|
||||||
title: "Users"
|
title: "Users"
|
||||||
likes_given: "Given"
|
likes_given: "Given"
|
||||||
likes_received: "Received"
|
likes_received: "Received"
|
||||||
topics_entered: "Topics Entered"
|
topics_entered: "Entered"
|
||||||
|
topics_entered_long: "Topics Entered"
|
||||||
time_read: "Time Read"
|
time_read: "Time Read"
|
||||||
topic_count: "Topics"
|
topic_count: "Topics"
|
||||||
|
topic_count_long: "Topics Created"
|
||||||
post_count: "Replies"
|
post_count: "Replies"
|
||||||
|
post_count_long: "Replies Posted"
|
||||||
no_results: "No results were found."
|
no_results: "No results were found."
|
||||||
|
days_visited: "Visits"
|
||||||
|
days_visited_long: "Days Visited"
|
||||||
|
posts_read: "Read"
|
||||||
|
posts_read_long: "Posts Read"
|
||||||
total_rows:
|
total_rows:
|
||||||
one: "1 user"
|
one: "1 user"
|
||||||
other: "%{count} users"
|
other: "%{count} users"
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
class AddMoreToDirectoryItems < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :directory_items, :days_visited, :integer, null: false, default: 0
|
||||||
|
add_column :directory_items, :posts_read, :integer, null: false, default: 0
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue