Format backend, tweak frontend

This commit is contained in:
Jon Staab
2026-02-27 21:26:45 -08:00
parent a3f00aab37
commit e87eb0c30d
14 changed files with 289 additions and 83 deletions
+14 -13
View File
@@ -2,7 +2,8 @@ use anyhow::Result;
use sqlx::{Sqlite, SqlitePool, Transaction};
use crate::models::{
Invoice, InvoiceItem, NewInvoice, NewInvoiceItem, NewRelay, NewTenant, Relay, Tenant, UpdateRelay,
Invoice, InvoiceItem, NewInvoice, NewInvoiceItem, NewRelay, NewTenant, Relay, Tenant,
UpdateRelay,
};
#[derive(Clone)]
@@ -16,14 +17,12 @@ impl Repo {
}
pub async fn create_tenant(&self, tenant: &NewTenant) -> Result<()> {
sqlx::query(
"INSERT INTO tenants (pubkey, status, tenant_nwc_url) VALUES (?, ?, ?)",
)
.bind(&tenant.pubkey)
.bind(&tenant.status)
.bind(&tenant.tenant_nwc_url)
.execute(&self.pool)
.await?;
sqlx::query("INSERT INTO tenants (pubkey, status, tenant_nwc_url) VALUES (?, ?, ?)")
.bind(&tenant.pubkey)
.bind(&tenant.status)
.bind(&tenant.tenant_nwc_url)
.execute(&self.pool)
.await?;
Ok(())
}
@@ -123,10 +122,12 @@ impl Repo {
}
pub async fn suspend_relays_for_tenant(&self, tenant: &str) -> Result<()> {
sqlx::query("UPDATE relays SET status = 'suspended' WHERE tenant = ? AND status = 'active'")
.bind(tenant)
.execute(&self.pool)
.await?;
sqlx::query(
"UPDATE relays SET status = 'suspended' WHERE tenant = ? AND status = 'active'",
)
.bind(tenant)
.execute(&self.pool)
.await?;
Ok(())
}