Currently the users table stores both user IDs and usernames, which is unnecessary now that we have the CachedTwitchUser model.
This PR modifies the behavior of /twitch/subcount that instead of looking up the username in the users table directly, it checks the Twitch user cache and then uses the user ID from that and checks the users table to retrieve the OAuth token and do the call that way.
Because of this, /twitch/subcount and any other potential routes that require authentication with Twitch should handle name changes (and the API V3 removal) a lot better.
This also completely drops the username column from users, so it will have to rely on the CachedTwitchUser model or be queried by user ID directly.
Currently the
users
table stores both user IDs and usernames, which is unnecessary now that we have theCachedTwitchUser
model.This PR modifies the behavior of
/twitch/subcount
that instead of looking up the username in theusers
table directly, it checks the Twitch user cache and then uses the user ID from that and checks theusers
table to retrieve the OAuth token and do the call that way.Because of this,
/twitch/subcount
and any other potential routes that require authentication with Twitch should handle name changes (and the API V3 removal) a lot better.This also completely drops the
username
column fromusers
, so it will have to rely on theCachedTwitchUser
model or be queried by user ID directly.