⭐
Log in to mark this repository.
start-of-tiers-motd
a98ab0f · gmorell · 2026-01-17 03:54
Files changed
modified
src/data.rs
+4
−0
@@ -381,6 +381,7 @@ impl TierOps {
| 381 | 381 | db: &DatabaseConnection, |
| 382 | 382 | ppl_id: i32, |
| 383 | 383 | tier: String, |
| 384 | + sig_date_delta: Option<u32> | |
| 384 | 385 | ) -> Result<(), PplError> { |
| 385 | 386 | let t = tier::ActiveModel { |
| 386 | 387 | id: Default::default(), |
@@ -390,6 +391,7 @@ impl TierOps {
| 390 | 391 | symbol: Default::default(), |
| 391 | 392 | date_ins: Set(Local::now().date_naive()), |
| 392 | 393 | date_up: Set(Local::now().date_naive()), |
| 394 | + sig_date_delta: Set(sig_date_delta), | |
| 393 | 395 | }; |
| 394 | 396 | let tt = t.insert(db).await; |
| 395 | 397 | match tt { |
@@ -530,6 +532,7 @@ impl TierDefaultOps {
| 530 | 532 | enabled: bool, |
| 531 | 533 | color: String, |
| 532 | 534 | symbol: String, |
| 535 | + sig_date_delta: Option<u32> | |
| 533 | 536 | ) -> Result<(), PplError> { |
| 534 | 537 | let t = tier_defaults::ActiveModel { |
| 535 | 538 | id: Default::default(), |
@@ -540,6 +543,7 @@ impl TierDefaultOps {
| 540 | 543 | symbol: Set(Option::from(symbol)), |
| 541 | 544 | date_ins: Set(Local::now().date_naive()), |
| 542 | 545 | date_up: Set(Local::now().date_naive()), |
| 546 | + sig_date_delta: Set(sig_date_delta) | |
| 543 | 547 | }; |
| 544 | 548 | let tt = t.insert(db).await; |
| 545 | 549 | match tt { |
modified
src/do_add.rs
+1
−1
@@ -38,7 +38,7 @@ pub async fn do_add(args: &AddArgs, db: DatabaseConnection) -> Result<(), PplErr
| 38 | 38 | |
| 39 | 39 | match &args.tier { |
| 40 | 40 | None => Ok(()), |
| 41 | − Some(tier) => TierOps::create(&db, pp.id, tier.clone()).await, | |
| 41 | + Some(tier) => TierOps::create(&db, pp.id, tier.clone(), None).await, | |
| 42 | 42 | }?; |
| 43 | 43 | match &args.phone { |
| 44 | 44 | None => Ok(()), |
modified
src/do_init.rs
+1
−0
@@ -552,6 +552,7 @@ pub async fn run_init(
| 552 | 552 | symbol: Default::default(), |
| 553 | 553 | date_ins: Set(Local::now().date_naive()), |
| 554 | 554 | date_up: Set(Local::now().date_naive()), |
| 555 | + sig_date_delta: Default::default(), | |
| 555 | 556 | }) |
| 556 | 557 | .collect::<Vec<tier_defaults::ActiveModel>>(); |
| 557 | 558 |
modified
src/entities/tier.rs
+1
−0
@@ -13,6 +13,7 @@ pub struct Model {
| 13 | 13 | pub symbol: Option<String>, |
| 14 | 14 | pub date_ins: Date, |
| 15 | 15 | pub date_up: Date, |
| 16 | + pub sig_date_delta: Option<u32>, | |
| 16 | 17 | } |
| 17 | 18 | |
| 18 | 19 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] |
modified
src/entities/tier_defaults.rs
+1
−0
@@ -14,6 +14,7 @@ pub struct Model {
| 14 | 14 | pub symbol: Option<String>, |
| 15 | 15 | pub date_ins: Date, |
| 16 | 16 | pub date_up: Date, |
| 17 | + pub sig_date_delta: Option<u32>, | |
| 17 | 18 | } |
| 18 | 19 | |
| 19 | 20 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] |
modified
src/main.rs
+3
−1
@@ -117,7 +117,9 @@ async fn main() -> Result<(), PplError> {
| 117 | 117 | println!("ppl"); |
| 118 | 118 | // show().expect("failed2draw") |
| 119 | 119 | } |
| 120 | − Some(Commands::MOTD { .. }) => {} | |
| 120 | + Some(Commands::MOTD { .. }) => { | |
| 121 | + | |
| 122 | + } | |
| 121 | 123 | Some(Commands::Init { .. }) => match is_init { |
| 122 | 124 | false => { |
| 123 | 125 | info!("Uninitialized"); |
added
src/migrator/m20260116_000010_add_sig_date_delta_to_tier.rs
+46
−0
@@ -0,0 +1,46 @@
| 1 | +use sea_orm::sea_query::{ColumnDef, Table}; | |
| 2 | +use sea_orm::{DbErr, DeriveIden}; | |
| 3 | +use sea_orm_migration::{MigrationName, MigrationTrait, SchemaManager}; | |
| 4 | + | |
| 5 | +pub struct Migration; | |
| 6 | + | |
| 7 | +impl MigrationName for Migration { | |
| 8 | + fn name(&self) -> &str { | |
| 9 | + "m_20260116_000010_add_sig_date_delta_to_tier" | |
| 10 | + } | |
| 11 | +} | |
| 12 | + | |
| 13 | +#[async_trait::async_trait] | |
| 14 | +impl MigrationTrait for Migration { | |
| 15 | + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { | |
| 16 | + manager | |
| 17 | + .alter_table( | |
| 18 | + Table::alter() | |
| 19 | + .table(Tier::Table) | |
| 20 | + .add_column( | |
| 21 | + ColumnDef::new(Tier::SigDateDelta) | |
| 22 | + .unsigned() | |
| 23 | + .null(), | |
| 24 | + ) | |
| 25 | + .to_owned(), | |
| 26 | + ) | |
| 27 | + .await | |
| 28 | + } | |
| 29 | + | |
| 30 | + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { | |
| 31 | + manager | |
| 32 | + .alter_table( | |
| 33 | + Table::alter() | |
| 34 | + .table(Tier::Table) | |
| 35 | + .drop_column(Tier::SigDateDelta) | |
| 36 | + .to_owned(), | |
| 37 | + ) | |
| 38 | + .await | |
| 39 | + } | |
| 40 | +} | |
| 41 | + | |
| 42 | +#[derive(DeriveIden)] | |
| 43 | +pub enum Tier { | |
| 44 | + Table, | |
| 45 | + SigDateDelta, | |
| 46 | +} |
added
src/migrator/m20260116_000011_add_sig_date_delta_to_tier_defaults.rs
+46
−0
@@ -0,0 +1,46 @@
| 1 | +use sea_orm::sea_query::{ColumnDef, Table}; | |
| 2 | +use sea_orm::{DbErr, DeriveIden}; | |
| 3 | +use sea_orm_migration::{MigrationName, MigrationTrait, SchemaManager}; | |
| 4 | + | |
| 5 | +pub struct Migration; | |
| 6 | + | |
| 7 | +impl MigrationName for Migration { | |
| 8 | + fn name(&self) -> &str { | |
| 9 | + "m_20260116_000011_add_sig_date_delta_to_tier_defaults" | |
| 10 | + } | |
| 11 | +} | |
| 12 | + | |
| 13 | +#[async_trait::async_trait] | |
| 14 | +impl MigrationTrait for Migration { | |
| 15 | + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { | |
| 16 | + manager | |
| 17 | + .alter_table( | |
| 18 | + Table::alter() | |
| 19 | + .table(TierDefaults::Table) | |
| 20 | + .add_column( | |
| 21 | + ColumnDef::new(TierDefaults::SigDateDelta) | |
| 22 | + .unsigned() | |
| 23 | + .null(), | |
| 24 | + ) | |
| 25 | + .to_owned(), | |
| 26 | + ) | |
| 27 | + .await | |
| 28 | + } | |
| 29 | + | |
| 30 | + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { | |
| 31 | + manager | |
| 32 | + .alter_table( | |
| 33 | + Table::alter() | |
| 34 | + .table(TierDefaults::Table) | |
| 35 | + .drop_column(TierDefaults::SigDateDelta) | |
| 36 | + .to_owned(), | |
| 37 | + ) | |
| 38 | + .await | |
| 39 | + } | |
| 40 | +} | |
| 41 | + | |
| 42 | +#[derive(DeriveIden)] | |
| 43 | +pub enum TierDefaults { | |
| 44 | + Table, | |
| 45 | + SigDateDelta, | |
| 46 | +} |
modified
src/migrator/mod.rs
+4
−0
@@ -9,6 +9,8 @@ mod m20241220_000006_create_relation;
| 9 | 9 | mod m20241220_000007_create_tier; |
| 10 | 10 | mod m20241222_000008_create_traitsettings; |
| 11 | 11 | mod m20241222_000009_create_tiersettings; |
| 12 | +mod m20260116_000010_add_sig_date_delta_to_tier; | |
| 13 | +mod m20260116_000011_add_sig_date_delta_to_tier_defaults; | |
| 12 | 14 | |
| 13 | 15 | pub struct Migrator; |
| 14 | 16 |
@@ -25,6 +27,8 @@ impl MigratorTrait for Migrator {
| 25 | 27 | Box::new(m20241220_000007_create_tier::Migration), |
| 26 | 28 | Box::new(m20241222_000008_create_traitsettings::Migration), |
| 27 | 29 | Box::new(m20241222_000009_create_tiersettings::Migration), |
| 30 | + Box::new(m20260116_000010_add_sig_date_delta_to_tier::Migration), | |
| 31 | + Box::new(m20260116_000011_add_sig_date_delta_to_tier_defaults::Migration), | |
| 28 | 32 | ] |
| 29 | 33 | } |
| 30 | 34 | } |
Parents: 30ac3be