-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ammon Smith
committed
Nov 27, 2017
1 parent
c091fb1
commit 968903e
Showing
5 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# statbot-queries | ||
A list of queries useful for a Statbot dataset | ||
A list of queries useful for a [Statbot](https://github.com/strinking/statbot) dataset. | ||
|
||
Available under the terms of the [MIT License](LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-- Lists all channels by number of messages. | ||
|
||
SELECT channels.name, t.* | ||
FROM ( | ||
SELECT channel_id, count(*) | ||
FROM messages | ||
WHERE guild_id = 181866934353133570 -- Programming | ||
GROUP BY channel_id | ||
) AS t | ||
JOIN channels | ||
ON channels.channel_id = t.channel_id | ||
ORDER BY channels.name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
-- This query measures the "meme" ratio of our guild. | ||
-- Really this is just what percentage of a person's | ||
-- posts are in #general vs. the rest of the guild. | ||
-- Since percentages for people with low post counts | ||
-- can be skewed, this query will ignore those with | ||
-- fewer than 400 messages total. | ||
|
||
SELECT | ||
users.name, | ||
totals.user_id, | ||
100.0 * general.count / totals.count as percentage, | ||
totals.count as total_messages | ||
FROM ( | ||
SELECT | ||
user_id, | ||
COUNT(user_id) | ||
FROM messages | ||
WHERE guild_id = 181866934353133570 -- Programming | ||
GROUP BY user_id | ||
) as totals | ||
JOIN ( | ||
SELECT | ||
user_id, | ||
COUNT(user_id) | ||
FROM messages | ||
WHERE channel_id = 181866934353133570 -- #general | ||
GROUP BY user_id | ||
) as general | ||
ON totals.user_id = general.user_id | ||
JOIN users | ||
ON totals.user_id = users.user_id | ||
WHERE totals.count > 400 -- Limit to people 400 posts or more | ||
GROUP BY totals.user_id, general.count, totals.count, users.name | ||
ORDER BY percentage DESC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- This query extracts YouTube URLs from #music. | ||
-- It works on messages with multiple links, and | ||
-- doesn't need any regex or parsing since it | ||
-- just queries the list of embeds. | ||
|
||
SELECT DISTINCT json_array_elements(embeds::json)->>'url' AS url | ||
FROM messages | ||
WHERE channel_id = 280778849615216640 -- #music | ||
AND ( | ||
content LIKE '%youtube.com/watch%' | ||
OR content LIKE '%youtube.com/playlist%' | ||
OR content LIKE '%youtu.be/%' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- This query counts how many messages have embeds, | ||
-- but were not made by bot accounts. | ||
-- This means that they are running selfbots. | ||
|
||
SELECT count(*) | ||
FROM messages | ||
JOIN users | ||
ON messages.user_id = users.user_id | ||
WHERE messages.guild_id = 181866934353133570 -- Programming | ||
AND messages.embeds != '[]' | ||
AND NOT users.is_bot; |