Compare commits

...

3 Commits

Author SHA1 Message Date
c9b6ce8f60 fix: Typo in community schema. 2025-09-04 01:08:32 +10:00
0363dc2bcd Catch IndexError for user upgrade. 2025-09-02 09:04:14 +10:00
ce46bd49fe fix: Remove transaction block. 2025-09-02 08:57:04 +10:00
2 changed files with 24 additions and 26 deletions

View File

@@ -41,7 +41,7 @@ CREATE UNIQUE INDEX profiles_twitch_userid ON profiles_twitch (userid);
CREATE TABLE communities(
communityid INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
migrated INTEGER REFERENCES user_profiles (profileid) ON DELETE CASCADE ON UPDATE CASCADE,
migrated INTEGER REFERENCES communities (communityid) ON DELETE CASCADE ON UPDATE CASCADE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
last_seen TIMESTAMPTZ NOT NULL DEFAULT NOW(),
_timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW()

View File

@@ -41,9 +41,7 @@ class ProfilesComponent(cmds.Component):
Fetch or create the profile for the given user.
"""
userid = str(user.id)
async with self.bot.dbconn.connection() as conn:
self.bot.dbconn.conn = conn
async with conn.transaction():
# TODO: Transaction
profile = await self.profiles.get_profile_twitch(userid)
if profile is None:
args = {}
@@ -53,6 +51,8 @@ class ProfilesComponent(cmds.Component):
args['avatar'] = user.profile_image.url
except twitchio.HTTPException:
pass
except IndexError:
pass
profile = await UserProfile.create(**args)
await TwitchProfileLink.create(profileid=profile.profileid, userid=userid)
elif touch:
@@ -70,9 +70,7 @@ class ProfilesComponent(cmds.Component):
Fetch or create the community for this channel.
"""
chanid = channel.id
async with self.bot.dbconn.connection() as conn:
self.bot.dbconn.conn = conn
async with conn.transaction():
# TODO: Transaction
comm = await self.profiles.get_community_twitch(chanid)
if comm is None:
comm = await Community.create()