fix queries

This commit is contained in:
Brandon Thomas committed 2022-01-12 00:17:08 -05:00
1 parent 405834f2d6
commit fdaa4a2eef
3 files changed
+17 -13

No files matched your search

@@ -13,14 +13,14 @@ pub struct TwitchOauthTokenRecord {
pub maybe_gravatar_hash: Option<String>,
/// Twitch user
//pub twitch_user_id: u32,
pub twitch_user_id: String,
pub maybe_twitch_username: Option<String>,
/// Token details
pub access_token: String,
pub maybe_refresh_token: Option<String>,
pub token_type: Option<String>,
//pub expires_in_seconds: Option<u32>,
pub expires_in_seconds: Option<u32>,
pub has_bits_read: bool,
pub has_channel_read_subscriptions: bool,
pub has_channel_read_redemptions: bool,
@@ -76,12 +76,12 @@ impl TwitchOauthTokenFinder {
maybe_user_token: record.maybe_user_token.clone(),
maybe_display_name: record.maybe_display_name.clone(),
maybe_gravatar_hash: record.maybe_gravatar_hash.clone(),
//twitch_user_id: record.twitch_user_id,
twitch_user_id: record.twitch_user_id.clone(),
maybe_twitch_username: record.maybe_twitch_username.clone(),
access_token: record.access_token.clone(),
maybe_refresh_token: record.maybe_refresh_token.clone(),
token_type: record.token_type.clone(),
//expires_in_seconds: record.expires_in_seconds.clone(),
expires_in_seconds: record.expires_in_seconds.clone(),
has_bits_read: i8_to_bool(record.has_bits_read),
has_channel_read_subscriptions: i8_to_bool(record.has_channel_read_subscriptions),
has_channel_read_redemptions: i8_to_bool(record.has_channel_read_redemptions),
@@ -226,7 +226,7 @@ LEFT OUTER JOIN users
}
}
#[derive(Serialize)]
#[derive(sqlx::FromRow)]
pub struct TwitchOauthTokenRecordInternal {
/// NB: Vocodes/FakeYou/Storyteller user
pub maybe_user_token: Option<String>,
@@ -234,14 +234,14 @@ pub struct TwitchOauthTokenRecordInternal {
pub maybe_gravatar_hash: Option<String>,
/// Twitch user
//pub twitch_user_id: u32,
pub twitch_user_id: String,
pub maybe_twitch_username: Option<String>,
/// Token details
pub access_token: String,
pub maybe_refresh_token: Option<String>,
pub token_type: Option<String>,
//pub expires_in_seconds: Option<u32>,
pub expires_in_seconds: Option<u32>,
pub has_bits_read: i8,
pub has_channel_read_subscriptions: i8,
pub has_channel_read_redemptions: i8,
@@ -8,8 +8,9 @@ use sqlx::MySqlPool;
pub struct TwitchOauthTokenInsertBuilder {
// ===== Required Fields =====
/// Exactly an INT(10) ~= UNSIGNED INTEGER
twitch_user_id: u32,
/// Old APIs return a u32, but this should be a string.
/// Twitch is migrating IDs to strings.
twitch_user_id: String,
access_token: String,
@@ -40,9 +41,9 @@ pub struct TwitchOauthTokenInsertBuilder {
}
impl TwitchOauthTokenInsertBuilder {
pub fn new(twitch_user_id: u32, access_token: &str) -> Self {
pub fn new(twitch_user_id: &str, access_token: &str) -> Self {
Self {
twitch_user_id,
twitch_user_id: twitch_user_id.to_string(),
access_token: access_token.to_string(),
maybe_refresh_token: None,
maybe_user_token: None,
@@ -82,7 +83,6 @@ impl TwitchOauthTokenInsertBuilder {
self
}
pub fn set_expires_in_seconds(mut self, expires_in_seconds: Option<u32>) -> Self {
self.expires_in_seconds = expires_in_seconds;
self
@@ -20,7 +20,11 @@ CREATE TABLE twitch_oauth_tokens(
-- The user ID / channel ID are the same
-- https://discuss.dev.twitch.tv/t/what-is-the-difference-between-the-stream--id-and-channel--id/4423
twitch_user_id INT(10) UNSIGNED NOT NULL,
-- Several suggest this should be a string and not an integer
-- https://discuss.dev.twitch.tv/t/type-of-user-id-in-api-responses/10205
-- Yep, strings
-- https://discuss.dev.twitch.tv/t/bug-v5-api-returns--id-as-string-for-featured-channels/10310
twitch_user_id VARCHAR(64) NOT NULL,
-- Usernames are between 4 and 25 characters.
maybe_twitch_username VARCHAR(32) DEFAULT NULL,