Skip to content

Commit

Permalink
The twitch api for subs doesn't return primes so this was all useless
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaserlang committed Feb 26, 2024
1 parent fca23b6 commit 54943eb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 147 deletions.
12 changes: 12 additions & 0 deletions tbot/migrations/20240226_03_eKhC6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""
"""

from yoyo import step

__depends__ = {'20240226_02_QLusc'}

steps = [
step('drop table twitch_sub_stats'),
step('drop table twitch_subs'),
]
35 changes: 0 additions & 35 deletions tbot/twitch_bot/modlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,6 @@ def created_by_user_id():

async def log_sub(self, data):
try:
# If the viewer is upgrading from a gifted sub or a prime sub,
# the partner plus points are first awarded the next month.
# This month
is_already_prime_or_gifted = await self.db.fetchone('''
SELECT 1
FROM twitch_sub_log
WHERE
channel_id=%s
AND user_id=%s
AND created_at > NOW() - INTERVAL 1 MONTH
AND (is_gift=1 OR tier='Prime')
''', (data['channel_id'], data['user_id'],))

await self.db.execute('''
INSERT INTO twitch_sub_log (channel_id, created_at, user_id, plan_name, tier, gifter_id, is_gift, total) VALUES
(%s, %s, %s, %s, %s, %s, %s, %s)
Expand All @@ -130,28 +117,6 @@ async def log_sub(self, data):
data['is_gift'],
data.get('cumulative_months'),
))

points = 1
if data['sub_plan'] == '2000':
points = 2
elif data['sub_plan'] == '3000':
points = 6
if not is_already_prime_or_gifted:
await self.db.execute('''
INSERT INTO twitch_sub_stats (channel_id, self_sub_points, gifted_sub_points, primes, updated_at) VALUES
(%s, %s, %s, %s, %s)
ON DUPLICATE KEY UPDATE
self_sub_points=self_sub_points+VALUES(self_sub_points),
gifted_sub_points=gifted_sub_points+VALUES(gifted_sub_points),
primes=primes+VALUES(primes),
updated_at=VALUES(updated_at)
''', (
data['channel_id'],
points if not data['is_gift'] else 0,
points if data['is_gift'] else 0,
points if data['sub_plan'] == 'Prime' else 0,
datetime.utcnow(),
))
except Exception as e:
logger.exception(e)

Expand Down
112 changes: 0 additions & 112 deletions tbot/twitch_bot/tasks/count_subs.py

This file was deleted.

0 comments on commit 54943eb

Please sign in to comment.