Skip to content

Commit

Permalink
queries: add blacklist to exlucde bots users (pingcap#1646)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mini256 authored Sep 26, 2023
1 parent 660c00a commit d58a6d5
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ WHERE
{% endcase %}
{% if excludeBots %}
-- Exclude bot users.
AND user_login NOT LIKE '%bot%'
AND LOWER(user_login) NOT LIKE '%bot%'
AND user_login NOT IN (SELECT login FROM blacklist_users LIMIT 255)
{% endif %}
GROUP BY user_login
ORDER BY 2 DESC
Expand Down
6 changes: 4 additions & 2 deletions configs/queries/orgs/participants/active/total/template.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ WITH repos AS (
{% endcase %}
{% if excludeBots %}
-- Exclude bot users.
AND user_login NOT LIKE '%bot%'
AND LOWER(user_login) NOT LIKE '%bot%'
AND user_login NOT IN (SELECT login FROM blacklist_users LIMIT 255)
{% endif %}
), past_period_active_participants AS (
SELECT
Expand All @@ -44,7 +45,8 @@ WITH repos AS (
{% endcase %}
{% if excludeBots %}
-- Exclude bot users.
AND user_login NOT LIKE '%bot%'
AND LOWER(user_login) NOT LIKE '%bot%'
AND user_login NOT IN (SELECT login FROM blacklist_users LIMIT 255)
{% endif %}
)
SELECT
Expand Down
3 changes: 2 additions & 1 deletion configs/queries/orgs/participants/active/trends/template.sql
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ WITH RECURSIVE seq(idx, current_period_day, past_period_day) AS (
{% endcase %}
{% if excludeBots %}
-- Exclude bot users.
AND user_login NOT LIKE '%bot%'
AND LOWER(user_login) NOT LIKE '%bot%'
AND user_login NOT IN (SELECT login FROM blacklist_users LIMIT 255)
{% endif %}
GROUP BY 1
) sub
Expand Down
3 changes: 2 additions & 1 deletion configs/queries/orgs/participants/engagements/template.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ WITH repos AS (
{% endcase %}
{% if excludeBots %}
-- Exclude bot users.
AND user_login NOT LIKE '%bot%'
AND LOWER(user_login) NOT LIKE '%bot%'
AND user_login NOT IN (SELECT login FROM blacklist_users LIMIT 255)
{% endif %}
GROUP BY user_login
)
Expand Down
3 changes: 2 additions & 1 deletion configs/queries/orgs/participants/locations/template.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ WITH repos AS (
{% endcase %}
{% if excludeBots %}
-- Exclude bot users.
AND ge.actor_login NOT LIKE '%bot%'
AND LOWER(ge.actor_login) NOT LIKE '%bot%'
AND ge.actor_login NOT IN (SELECT login FROM blacklist_users LIMIT 255)
{% endif %}
{% if excludeUnknown %}
-- Exclude users with no country code.
Expand Down
3 changes: 2 additions & 1 deletion configs/queries/orgs/participants/new/ranking/template.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ WHERE
{% endcase %}
{% if excludeBots %}
-- Exclude bot users.
AND user_login NOT LIKE '%bot%'
AND LOWER(user_login) NOT LIKE '%bot%'
AND user_login NOT IN (SELECT login FROM blacklist_users LIMIT 255)
{% endif %}
GROUP BY user_login
ORDER BY first_participated_at DESC
Expand Down
6 changes: 4 additions & 2 deletions configs/queries/orgs/participants/new/total/template.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ WITH repos AS (
{% endcase %}
{% if excludeBots %}
-- Exclude bot users.
AND mrp.user_login NOT LIKE '%bot%'
AND LOWER(user_login) NOT LIKE '%bot%'
AND user_login NOT IN (SELECT login FROM blacklist_users LIMIT 255)
{% endif %}
), past_period_new_participants AS (
SELECT
Expand All @@ -44,7 +45,8 @@ WITH repos AS (
{% endcase %}
{% if excludeBots %}
-- Exclude bot users.
AND mrp.user_login NOT LIKE '%bot%'
AND LOWER(user_login) NOT LIKE '%bot%'
AND user_login NOT IN (SELECT login FROM blacklist_users LIMIT 255)
{% endif %}
)
SELECT
Expand Down
3 changes: 2 additions & 1 deletion configs/queries/orgs/participants/new/trends/template.sql
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ WITH RECURSIVE seq(idx, current_period_day, past_period_day) AS (
{% endcase %}
{% if excludeBots %}
-- Exclude bot users.
AND user_login NOT LIKE '%bot%'
AND LOWER(user_login) NOT LIKE '%bot%'
AND user_login NOT IN (SELECT login FROM blacklist_users LIMIT 255)
{% endif %}
AND np.first_engagement_at >= day
GROUP BY 1
Expand Down
3 changes: 2 additions & 1 deletion configs/queries/orgs/participants/organizations/template.sql
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ WITH repos AS (
{% endcase %}
{% if excludeBots %}
-- Exclude bot users.
AND ge.actor_login NOT LIKE '%bot%'
AND LOWER(ge.actor_login) NOT LIKE '%bot%'
AND ge.actor_login NOT IN (SELECT login FROM blacklist_users LIMIT 255)
{% endif %}
{% if excludeUnknown %}
-- Exclude users with no organization.
Expand Down
3 changes: 2 additions & 1 deletion configs/queries/orgs/participants/trends/template.sql
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ WITH RECURSIVE seq(idx, current_period_day, past_period_day) AS (
{% endcase %}
{% if excludeBots %}
-- Exclude bot users.
AND user_login NOT LIKE '%bot%'
AND LOWER(user_login) NOT LIKE '%bot%'
AND user_login NOT IN (SELECT login FROM blacklist_users LIMIT 255)
{% endif %}
GROUP BY 1
) sub
Expand Down

0 comments on commit d58a6d5

Please sign in to comment.