Prod DB issue with integer types caused by import; adjust internal types to match
Badgey Deployment / build (push) Successful in 5m50s
Details
Badgey Deployment / build (push) Successful in 5m50s
Details
This commit is contained in:
parent
2917b20d71
commit
d4a5cb08e6
|
|
@ -159,7 +159,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "badgey"
|
name = "badgey"
|
||||||
version = "3.0.0"
|
version = "3.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"built",
|
"built",
|
||||||
"clap",
|
"clap",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "badgey"
|
name = "badgey"
|
||||||
version = "3.0.1"
|
version = "3.0.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
CREATE TABLE IF NOT EXISTS "xp"
|
CREATE TABLE IF NOT EXISTS "xp"
|
||||||
(
|
(
|
||||||
user_id BIGINT NOT NULL REFERENCES userinfo(user_id) PRIMARY KEY,
|
user_id BIGINT NOT NULL REFERENCES userinfo(user_id) PRIMARY KEY,
|
||||||
user_current_level INTEGER NOT NULL DEFAULT 0,
|
user_current_level BIGINT NOT NULL DEFAULT 0,
|
||||||
xp_value BIGINT NOT NULL DEFAULT 0,
|
xp_value BIGINT NOT NULL DEFAULT 0,
|
||||||
last_given_xp BIGINT,
|
last_given_xp BIGINT,
|
||||||
rank_track INTEGER NOT NULL,
|
rank_track BIGINT NOT NULL,
|
||||||
rank_track_last_changed BIGINT,
|
rank_track_last_changed BIGINT,
|
||||||
freeze_rank BIGINT,
|
freeze_rank BIGINT,
|
||||||
freeze_rank_last_changed BIGINT
|
freeze_rank_last_changed BIGINT
|
||||||
|
|
@ -12,15 +12,15 @@ CREATE TABLE IF NOT EXISTS "xp"
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS "tracks"
|
CREATE TABLE IF NOT EXISTS "tracks"
|
||||||
(
|
(
|
||||||
track_id INTEGER NOT NULL PRIMARY KEY,
|
track_id BIGINT NOT NULL PRIMARY KEY,
|
||||||
track_name VARCHAR(128) NOT NULL
|
track_name VARCHAR(128) NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS "ranks"
|
CREATE TABLE IF NOT EXISTS "ranks"
|
||||||
(
|
(
|
||||||
role_id BIGINT NOT NULL PRIMARY KEY,
|
role_id BIGINT NOT NULL PRIMARY KEY,
|
||||||
required_level INTEGER NOT NULL DEFAULT 1,
|
required_level BIGINT NOT NULL DEFAULT 1,
|
||||||
rank_track INTEGER NOT NULL DEFAULT 0,
|
rank_track BIGINT NOT NULL DEFAULT 0,
|
||||||
rank_name VARCHAR(128) NOT NULL
|
rank_name VARCHAR(128) NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use built::chrono;
|
use built::chrono;
|
||||||
use manifold::error::{ManifoldError, ManifoldResult};
|
use manifold::error::{ManifoldError, ManifoldResult};
|
||||||
use manifold::{ManifoldContext, ManifoldData};
|
use manifold::{ManifoldContext, ManifoldData};
|
||||||
|
use poise::serenity_prelude::{Mentionable, RoleId};
|
||||||
use crate::badgey::models::xp::{Rank, Track, Xp};
|
use crate::badgey::models::xp::{Rank, Track, Xp};
|
||||||
|
|
||||||
#[poise::command(prefix_command, slash_command)]
|
#[poise::command(prefix_command, slash_command)]
|
||||||
|
|
@ -108,7 +109,7 @@ async fn rank(ctx: ManifoldContext<'_>) -> ManifoldResult<()> {
|
||||||
let next_level_xp = xp.get_xp_to_next_level();
|
let next_level_xp = xp.get_xp_to_next_level();
|
||||||
let next_rank_xp = xp.get_xp_to_next_rank(&db).unwrap_or(0);
|
let next_rank_xp = xp.get_xp_to_next_rank(&db).unwrap_or(0);
|
||||||
|
|
||||||
let mut response = format!("You're currently {}. You need {} more XP to get to the next level", current_rank.rank_name, next_level_xp);
|
let mut response = format!("You're currently {}. You need {} more XP to get to the next level", RoleId::from(current_rank.role_id as u64).mention(), next_level_xp);
|
||||||
if next_rank_xp == 0 {
|
if next_rank_xp == 0 {
|
||||||
response = format!("{}. There are no more ranks for you - you can't be promoted any further!", response);
|
response = format!("{}. There are no more ranks for you - you can't be promoted any further!", response);
|
||||||
} else if next_rank_xp == next_level_xp {
|
} else if next_rank_xp == next_level_xp {
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,10 @@ use crate::badgey::schema::*;
|
||||||
#[diesel(treat_none_as_null = true)]
|
#[diesel(treat_none_as_null = true)]
|
||||||
pub struct Xp {
|
pub struct Xp {
|
||||||
pub user_id: i64,
|
pub user_id: i64,
|
||||||
pub user_current_level: i32,
|
pub user_current_level: i64,
|
||||||
pub xp_value: i64,
|
pub xp_value: i64,
|
||||||
pub last_given_xp: Option<i64>,
|
pub last_given_xp: Option<i64>,
|
||||||
pub rank_track: i32,
|
pub rank_track: i64,
|
||||||
pub rank_track_last_changed: Option<i64>,
|
pub rank_track_last_changed: Option<i64>,
|
||||||
pub freeze_rank: Option<i64>,
|
pub freeze_rank: Option<i64>,
|
||||||
pub freeze_rank_last_changed: Option<i64>
|
pub freeze_rank_last_changed: Option<i64>
|
||||||
|
|
@ -29,15 +29,15 @@ pub struct Xp {
|
||||||
#[diesel(primary_key(role_id))]
|
#[diesel(primary_key(role_id))]
|
||||||
pub struct Rank {
|
pub struct Rank {
|
||||||
pub role_id: i64,
|
pub role_id: i64,
|
||||||
pub required_level: i32,
|
pub required_level: i64,
|
||||||
pub rank_track: i32,
|
pub rank_track: i64,
|
||||||
pub rank_name: String,
|
pub rank_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Queryable, Selectable, Identifiable, Debug, Clone)]
|
#[derive(Queryable, Selectable, Identifiable, Debug, Clone)]
|
||||||
#[diesel(primary_key(track_id))]
|
#[diesel(primary_key(track_id))]
|
||||||
pub struct Track {
|
pub struct Track {
|
||||||
pub track_id: i32,
|
pub track_id: i64,
|
||||||
pub track_name: String,
|
pub track_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,8 +76,8 @@ impl Xp {
|
||||||
.map_err(|e| ManifoldError::from(e))
|
.map_err(|e| ManifoldError::from(e))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_level_from_xp(&self) -> i32 {
|
pub fn get_level_from_xp(&self) -> i64 {
|
||||||
(0.125 * f64::sqrt(self.xp_value.clone() as f64)) as i32
|
(0.125 * f64::sqrt(self.xp_value.clone() as f64)) as i64
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_xp_to_next_level(&self) -> i64 {
|
pub fn get_xp_to_next_level(&self) -> i64 {
|
||||||
|
|
@ -116,7 +116,7 @@ impl Rank {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_rank_for_level(conn: &Db, level: &i32, track: &i32) -> ManifoldResult<Self> {
|
pub fn get_rank_for_level(conn: &Db, level: &i64, track: &i64) -> ManifoldResult<Self> {
|
||||||
Ok(ranks::table
|
Ok(ranks::table
|
||||||
.filter(ranks::required_level.le(level))
|
.filter(ranks::required_level.le(level))
|
||||||
.filter(ranks::rank_track.eq(track))
|
.filter(ranks::rank_track.eq(track))
|
||||||
|
|
@ -126,7 +126,7 @@ impl Rank {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_next_rank_for_level(conn: &Db, level: &i32, track: &i32) -> ManifoldResult<Self> {
|
pub fn get_next_rank_for_level(conn: &Db, level: &i64, track: &i64) -> ManifoldResult<Self> {
|
||||||
Ok(ranks::table
|
Ok(ranks::table
|
||||||
.filter(ranks::required_level.gt(level))
|
.filter(ranks::required_level.gt(level))
|
||||||
.filter(ranks::rank_track.eq(track))
|
.filter(ranks::rank_track.eq(track))
|
||||||
|
|
@ -136,7 +136,7 @@ impl Rank {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_rank_by_name(conn: &Db, needle: &String, track: &i32) -> ManifoldResult<Rank> {
|
pub fn get_rank_by_name(conn: &Db, needle: &String, track: &i64) -> ManifoldResult<Rank> {
|
||||||
Ok(ranks::table
|
Ok(ranks::table
|
||||||
.filter(ranks::rank_name.like(needle.trim().to_lowercase()))
|
.filter(ranks::rank_name.like(needle.trim().to_lowercase()))
|
||||||
.filter(ranks::rank_track.eq(track))
|
.filter(ranks::rank_track.eq(track))
|
||||||
|
|
@ -157,7 +157,7 @@ impl Track {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_track_by_id(conn: &Db, needle: &i32) -> ManifoldResult<Track> {
|
pub fn get_track_by_id(conn: &Db, needle: &i64) -> ManifoldResult<Track> {
|
||||||
Ok(tracks::table
|
Ok(tracks::table
|
||||||
.filter(tracks::track_id.eq(needle))
|
.filter(tracks::track_id.eq(needle))
|
||||||
.select(Track::as_select())
|
.select(Track::as_select())
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,15 @@
|
||||||
diesel::table! {
|
diesel::table! {
|
||||||
ranks (role_id) {
|
ranks (role_id) {
|
||||||
role_id -> BigInt,
|
role_id -> BigInt,
|
||||||
required_level -> Integer,
|
required_level -> BigInt,
|
||||||
rank_track -> Integer,
|
rank_track -> BigInt,
|
||||||
rank_name -> Text,
|
rank_name -> Text,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
diesel::table! {
|
diesel::table! {
|
||||||
tracks (track_id) {
|
tracks (track_id) {
|
||||||
track_id -> Integer,
|
track_id -> BigInt,
|
||||||
track_name -> Text,
|
track_name -> Text,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -30,10 +30,10 @@ diesel::table! {
|
||||||
diesel::table! {
|
diesel::table! {
|
||||||
xp (user_id) {
|
xp (user_id) {
|
||||||
user_id -> BigInt,
|
user_id -> BigInt,
|
||||||
user_current_level -> Integer,
|
user_current_level -> BigInt,
|
||||||
xp_value -> BigInt,
|
xp_value -> BigInt,
|
||||||
last_given_xp -> Nullable<BigInt>,
|
last_given_xp -> Nullable<BigInt>,
|
||||||
rank_track -> Integer,
|
rank_track -> BigInt,
|
||||||
rank_track_last_changed -> Nullable<BigInt>,
|
rank_track_last_changed -> Nullable<BigInt>,
|
||||||
freeze_rank -> Nullable<BigInt>,
|
freeze_rank -> Nullable<BigInt>,
|
||||||
freeze_rank_last_changed -> Nullable<BigInt>,
|
freeze_rank_last_changed -> Nullable<BigInt>,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue