ユーザーのアクティビティを追跡する方法は?

Hi all…

I really need your help to track our user activity with data explorer.

Input : Username and Date

The result from the query that I hope to get is like this,

Username Date topics_created post_created like_received total_words
User A 01-10-2019
02-01-2019
03-01-2019
31-01-2019
User B 01-10-2019
02-01-2019
03-01-2019
31-01-2019
User B 01-10-2019
02-01-2019
03-01-2019
31-01-2019
User C 01-10-2019
02-01-2019
03-01-2019
31-01-2019
User Z 01-10-2019
02-01-2019
03-01-2019
31-01-2019

Thank you very much for your help…

「いいね!」 2

I don’t think the inputs you have listed match the output you are hoping to get. If you would like to get data for a single user, something like the query below might work as a starting point. It’s using Common Table Expressions to make the query easier to read and write. The same pattern could be followed to add more data to the results.

One thing I wasn’t sure of is if you want the sum of the data for a given day, or the number of actions that took place on each day. For example, do you want to know that on 2019-10-31 a user has created a total of 20 posts in all the days they have been on the site, or do you want to know that on 2019-10-31 the user created exactly 3 posts? The way the query is currently structured, it’s returning the latter result.

--[params]
-- string :username
-- date :start_date

WITH target_user AS (SELECT id FROM users WHERE username = :username),
days AS (
SELECT day::date
FROM GENERATE_SERIES(:start_date, NOW()::date, INTERVAL '1 day') AS day
),
topics_created AS(
SELECT
tu.id,
day,
COUNT(tu.id) AS topics
FROM topics t
JOIN target_user tu
ON tu.id = t.user_id
JOIN days
ON t.created_at::date = day
WHERE t.archetype = 'regular'
AND t.deleted_at IS NULL
GROUP BY day, tu.id
),
posts_created AS(
SELECT
tu.id,
day,
COUNT(tu.id) AS posts,
SUM(array_length(regexp_split_to_array(raw, '\s'), 1)) AS word_count
FROM posts p
JOIN target_user tu
ON tu.id = p.user_id
JOIN days
ON p.created_at::date = day
WHERE p.post_type = 1
AND p.deleted_at IS NULL
GROUP BY day, tu.id
),
likes_received AS (
SELECT tu.id,
day,
COUNT(tu.id) AS likes_received_count
FROM user_actions ua
JOIN target_user tu
ON tu.id = ua.user_id
JOIN days
ON ua.created_at::date = day
WHERE ua.action_type = 2
GROUP BY day, tu.id
)

SELECT
d.day,
COALESCE(topics, 0) AS topics,
COALESCE(posts, 0) AS posts,
COALESCE(word_count, 0) AS word_count,
COALESCE(likes_received_count, 0) AS likes_received
FROM days d
LEFT JOIN topics_created tc
ON tc.day = d.day
LEFT JOIN posts_created pc
ON pc.day = d.day
LEFT JOIN likes_received lc
ON lc.day = d.day
ORDER BY d.day
「いいね!」 6

I want the number of actions that took place on each day, exactly like the query you give it to us…

Thank you very much sir, for your help… It really helps us…

「いいね!」 2

ユーザーの活動を活発化させるため、当フォーラムで最も活発なユーザーを表彰するチャレンジを開催する予定です。

そのため、チャレンジをさらに面白くするため、追加のデータ取得を検討しています。

@simon 氏によるクエリで現在取得しているデータは、トピック数、投稿数、単語数、受け取ったいいね数です

追加で取得したいデータには以下が含まれます:

  • 与えたいいね数: ユーザーが与えたいいねの数
  • 訪問回数: ユーザーがフォーラムを開いた回数
  • 閲覧時間: ユーザーがフォーラムに滞在した時間
  • フォロー数とフォロワー数
  • トピックの閲覧数: ユーザーが作成した全トピックの合計閲覧数
  • トピックへの返信数: ユーザーが作成した全トピックに寄せられた返信(投稿)数

これらの追加データを取得できるよう、ご協力をお願いいたします。

各項目の重み付けについては、Excel を使用して行う予定です。勝者を選定するための重み付けに関するご助言があれば、ぜひお聞かせください。

このチャレンジは真剣でありながらも楽しく行いたいと考えています。最高のユーザーとは、最も活発で、最も役立つ情報を提供し、かつ最も人気のある人の組み合わせです。 :partying_face: :partying_face: :partying_face:

引き続き、ご支援いただき誠にありがとうございます。

ご注意: データをグループ単位で取得することは可能でしょうか?そうすれば、グループ ID のみを指定するだけで済みます。今回の計画では、すべての参加者を一つのグループにまとめたいと考えています。現在、参加者のユーザー ID を一つずつ入力する必要があります。

「いいね!」 1

@manchestermania さん、こんにちは

同じマンチェスター出身者です :slight_smile:
私の会社では、従業員によるコミュニティへのエンゲージメントを高めるため、同様のコンペティションを社内で実施しようと考えています。

コンペティションは実際に実施されましたか?データはどのように収集されましたか?また、最終的にさまざまなエンゲージメント指標をどのように重み付けしましたか?

ぜひお話ししたいです!

ありがとうございます
ジュリア

「いいね!」 2