mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-01 23:35:40 -05:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0bba594a3 | ||
|
|
7ea40be748 | ||
|
|
358e04e9fe |
+168
@@ -0,0 +1,168 @@
|
||||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "\nSELECT\n u.id as `id: u64`,\n u.token as `token: tokens::tokens::users::UserToken`,\n u.username,\n u.display_name,\n u.username_is_not_customized as `username_is_not_customized: bool`,\n u.email_address,\n u.email_confirmed as `email_confirmed: bool`,\n u.is_without_password as `is_without_password: bool`,\n u.ip_address_creation,\n u.maybe_source as `maybe_source: enums::by_table::users::user_signup_source::UserSignupSource`,\n u.maybe_signup_method as `maybe_signup_method: enums::by_table::users::user_signup_method::UserSignupMethod`,\n u.created_at,\n u.maybe_referral_url,\n u.is_temporary as `is_temporary: bool`\nFROM users AS u\nWHERE\n u.id < ?\n AND u.user_deleted_at IS NULL\n AND u.mod_deleted_at IS NULL\nORDER BY u.id DESC\nLIMIT ?\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id: u64",
|
||||
"type_info": {
|
||||
"type": "LongLong",
|
||||
"flags": "NOT_NULL | PRIMARY_KEY | AUTO_INCREMENT",
|
||||
"char_set": 63,
|
||||
"max_size": 20
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "token: tokens::tokens::users::UserToken",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | UNIQUE_KEY | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 128
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "username",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | UNIQUE_KEY | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 80
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "display_name",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 80
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "username_is_not_customized: bool",
|
||||
"type_info": {
|
||||
"type": "Tiny",
|
||||
"flags": "NOT_NULL",
|
||||
"char_set": 63,
|
||||
"max_size": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 5,
|
||||
"name": "email_address",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | UNIQUE_KEY | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 1020
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 6,
|
||||
"name": "email_confirmed: bool",
|
||||
"type_info": {
|
||||
"type": "Tiny",
|
||||
"flags": "NOT_NULL",
|
||||
"char_set": 63,
|
||||
"max_size": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 7,
|
||||
"name": "is_without_password: bool",
|
||||
"type_info": {
|
||||
"type": "Tiny",
|
||||
"flags": "NOT_NULL",
|
||||
"char_set": 63,
|
||||
"max_size": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 8,
|
||||
"name": "ip_address_creation",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 160
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 9,
|
||||
"name": "maybe_source: enums::by_table::users::user_signup_source::UserSignupSource",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 1020
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 10,
|
||||
"name": "maybe_signup_method: enums::by_table::users::user_signup_method::UserSignupMethod",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 128
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 11,
|
||||
"name": "created_at",
|
||||
"type_info": {
|
||||
"type": "Timestamp",
|
||||
"flags": "NOT_NULL | BINARY | TIMESTAMP",
|
||||
"char_set": 63,
|
||||
"max_size": 19
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 12,
|
||||
"name": "maybe_referral_url",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 1020
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 13,
|
||||
"name": "is_temporary: bool",
|
||||
"type_info": {
|
||||
"type": "Tiny",
|
||||
"flags": "NOT_NULL",
|
||||
"char_set": 63,
|
||||
"max_size": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "2fe10ae5a2d013e1861f71dcb0afae4048e0d47c5b584c6bbc7df25dde747e87"
|
||||
}
|
||||
+289
@@ -0,0 +1,289 @@
|
||||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "\nSELECT\n u.id as `id: u64`,\n u.token as `token: tokens::tokens::users::UserToken`,\n u.username,\n u.display_name,\n u.username_is_not_customized as `username_is_not_customized: bool`,\n u.email_address,\n u.email_confirmed as `email_confirmed: bool`,\n u.is_without_password as `is_without_password: bool`,\n u.ip_address_creation,\n u.maybe_source as `maybe_source: enums::by_table::users::user_signup_source::UserSignupSource`,\n u.maybe_signup_method as `maybe_signup_method: enums::by_table::users::user_signup_method::UserSignupMethod`,\n u.created_at,\n u.maybe_referral_url,\n u.is_temporary as `is_temporary: bool`,\n us.subscription_namespace,\n us.subscription_product_slug,\n us.maybe_stripe_subscription_id,\n us.maybe_stripe_customer_id,\n us.maybe_stripe_product_id,\n us.maybe_stripe_price_id,\n us.maybe_stripe_subscription_status,\n us.maybe_stripe_recurring_interval,\n us.maybe_stripe_invoice_is_paid as `maybe_stripe_invoice_is_paid: bool`,\n us.maybe_cancel_at,\n us.maybe_canceled_at\nFROM users AS u\nINNER JOIN user_subscriptions AS us ON u.token = us.user_token\nWHERE\n u.id < ?\n AND u.user_deleted_at IS NULL\n AND u.mod_deleted_at IS NULL\nORDER BY u.id DESC\nLIMIT ?\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id: u64",
|
||||
"type_info": {
|
||||
"type": "LongLong",
|
||||
"flags": "NOT_NULL | PRIMARY_KEY | AUTO_INCREMENT",
|
||||
"char_set": 63,
|
||||
"max_size": 20
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "token: tokens::tokens::users::UserToken",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | UNIQUE_KEY | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 128
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "username",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | UNIQUE_KEY | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 80
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "display_name",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 80
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "username_is_not_customized: bool",
|
||||
"type_info": {
|
||||
"type": "Tiny",
|
||||
"flags": "NOT_NULL",
|
||||
"char_set": 63,
|
||||
"max_size": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 5,
|
||||
"name": "email_address",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | UNIQUE_KEY | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 1020
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 6,
|
||||
"name": "email_confirmed: bool",
|
||||
"type_info": {
|
||||
"type": "Tiny",
|
||||
"flags": "NOT_NULL",
|
||||
"char_set": 63,
|
||||
"max_size": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 7,
|
||||
"name": "is_without_password: bool",
|
||||
"type_info": {
|
||||
"type": "Tiny",
|
||||
"flags": "NOT_NULL",
|
||||
"char_set": 63,
|
||||
"max_size": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 8,
|
||||
"name": "ip_address_creation",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 160
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 9,
|
||||
"name": "maybe_source: enums::by_table::users::user_signup_source::UserSignupSource",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 1020
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 10,
|
||||
"name": "maybe_signup_method: enums::by_table::users::user_signup_method::UserSignupMethod",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 128
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 11,
|
||||
"name": "created_at",
|
||||
"type_info": {
|
||||
"type": "Timestamp",
|
||||
"flags": "NOT_NULL | BINARY | TIMESTAMP",
|
||||
"char_set": 63,
|
||||
"max_size": 19
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 12,
|
||||
"name": "maybe_referral_url",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 1020
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 13,
|
||||
"name": "is_temporary: bool",
|
||||
"type_info": {
|
||||
"type": "Tiny",
|
||||
"flags": "NOT_NULL",
|
||||
"char_set": 63,
|
||||
"max_size": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 14,
|
||||
"name": "subscription_namespace",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | MULTIPLE_KEY | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 128
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 15,
|
||||
"name": "subscription_product_slug",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | MULTIPLE_KEY | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 128
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 16,
|
||||
"name": "maybe_stripe_subscription_id",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "UNIQUE_KEY | BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 1020
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 17,
|
||||
"name": "maybe_stripe_customer_id",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "MULTIPLE_KEY | BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 1020
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 18,
|
||||
"name": "maybe_stripe_product_id",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "MULTIPLE_KEY | BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 1020
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 19,
|
||||
"name": "maybe_stripe_price_id",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 1020
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 20,
|
||||
"name": "maybe_stripe_subscription_status",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "MULTIPLE_KEY | BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 128
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 21,
|
||||
"name": "maybe_stripe_recurring_interval",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 128
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 22,
|
||||
"name": "maybe_stripe_invoice_is_paid: bool",
|
||||
"type_info": {
|
||||
"type": "Tiny",
|
||||
"flags": "",
|
||||
"char_set": 63,
|
||||
"max_size": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 23,
|
||||
"name": "maybe_cancel_at",
|
||||
"type_info": {
|
||||
"type": "Timestamp",
|
||||
"flags": "BINARY",
|
||||
"char_set": 63,
|
||||
"max_size": 19
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 24,
|
||||
"name": "maybe_canceled_at",
|
||||
"type_info": {
|
||||
"type": "Timestamp",
|
||||
"flags": "BINARY",
|
||||
"char_set": 63,
|
||||
"max_size": 19
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "83840fa1a0712a326a26ae146a819f67a44fae927f294780d89892270075ebb7"
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
use chrono::{DateTime, Utc};
|
||||
use enums::by_table::users::user_signup_method::UserSignupMethod;
|
||||
use enums::by_table::users::user_signup_source::UserSignupSource;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use tokens::tokens::users::UserToken;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
pub const MODERATOR_LIST_SUBSCRIBING_USERS_BY_SIGNUP_DATE_PATH: &str = "/v1/moderation/users/list_subscribers_by_signup_date";
|
||||
|
||||
#[derive(Deserialize, ToSchema)]
|
||||
pub struct ModeratorListSubscribingUsersBySignupDateRequest {
|
||||
/// Optional cursor for pagination. Pass the `next_cursor` from a previous response.
|
||||
pub id_cursor: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, ToSchema)]
|
||||
pub struct ModeratorListSubscribingUsersBySignupDateResponse {
|
||||
pub success: bool,
|
||||
pub users: Vec<ModeratorListSubscribingUsersBySignupDateEntry>,
|
||||
/// The cursor for the next page. `None` if there are no more results.
|
||||
pub next_cursor: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, ToSchema)]
|
||||
pub struct ModeratorListSubscribingUsersBySignupDateEntry {
|
||||
// -- User fields --
|
||||
pub id: u64,
|
||||
pub token: UserToken,
|
||||
pub username: String,
|
||||
pub display_name: String,
|
||||
pub username_is_not_customized: bool,
|
||||
pub email_address: String,
|
||||
pub email_confirmed: bool,
|
||||
pub is_without_password: bool,
|
||||
pub ip_address_creation: String,
|
||||
pub maybe_source: Option<UserSignupSource>,
|
||||
pub maybe_signup_method: Option<UserSignupMethod>,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub maybe_referral_url: Option<String>,
|
||||
pub is_temporary: bool,
|
||||
|
||||
// TODO: Use enum types/strong types -
|
||||
// -- Subscription fields --
|
||||
pub subscription_namespace: String,
|
||||
pub subscription_product_slug: String,
|
||||
pub maybe_stripe_subscription_id: Option<String>,
|
||||
pub maybe_stripe_customer_id: Option<String>,
|
||||
pub maybe_stripe_product_id: Option<String>,
|
||||
pub maybe_stripe_price_id: Option<String>,
|
||||
pub maybe_stripe_subscription_status: Option<String>,
|
||||
pub maybe_stripe_recurring_interval: Option<String>,
|
||||
pub maybe_stripe_invoice_is_paid: Option<bool>,
|
||||
pub maybe_cancel_at: Option<DateTime<Utc>>,
|
||||
pub maybe_canceled_at: Option<DateTime<Utc>>,
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
use chrono::{DateTime, Utc};
|
||||
use enums::by_table::users::user_signup_method::UserSignupMethod;
|
||||
use enums::by_table::users::user_signup_source::UserSignupSource;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use tokens::tokens::users::UserToken;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
pub const MODERATOR_LIST_USERS_BY_SIGNUP_DATE_PATH: &str = "/v1/moderation/users/list_all_by_signup_date";
|
||||
|
||||
#[derive(Deserialize, ToSchema)]
|
||||
pub struct ModeratorListUsersBySignupDateRequest {
|
||||
/// Optional cursor for pagination. Pass the `next_cursor` from a previous response.
|
||||
pub id_cursor: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, ToSchema)]
|
||||
pub struct ModeratorListUsersBySignupDateResponse {
|
||||
pub success: bool,
|
||||
pub users: Vec<ModeratorListUsersBySignupDateEntry>,
|
||||
/// The cursor for the next page. `None` if there are no more results.
|
||||
pub next_cursor: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, ToSchema)]
|
||||
pub struct ModeratorListUsersBySignupDateEntry {
|
||||
pub id: u64,
|
||||
pub token: UserToken,
|
||||
pub username: String,
|
||||
pub display_name: String,
|
||||
pub username_is_not_customized: bool,
|
||||
pub email_address: String,
|
||||
pub email_confirmed: bool,
|
||||
pub is_without_password: bool,
|
||||
pub ip_address_creation: String,
|
||||
pub maybe_source: Option<UserSignupSource>,
|
||||
pub maybe_signup_method: Option<UserSignupMethod>,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub maybe_referral_url: Option<String>,
|
||||
pub is_temporary: bool,
|
||||
}
|
||||
@@ -1,2 +1,4 @@
|
||||
pub mod list_subscribing_users_by_signup_date;
|
||||
pub mod list_users_by_signup_date;
|
||||
pub mod user_lookup;
|
||||
pub mod user_lookup_by_stripe_customer_id;
|
||||
pub mod user_lookup_by_stripe_customer_id;
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
use chrono::{DateTime, Utc};
|
||||
use log::warn;
|
||||
use sqlx::MySqlPool;
|
||||
|
||||
use enums::by_table::users::user_signup_method::UserSignupMethod;
|
||||
use enums::by_table::users::user_signup_source::UserSignupSource;
|
||||
use errors::AnyhowResult;
|
||||
use tokens::tokens::users::UserToken;
|
||||
|
||||
pub struct ListSubscribingUsersBySignupDateRow {
|
||||
pub id: u64,
|
||||
pub token: UserToken,
|
||||
pub username: String,
|
||||
pub display_name: String,
|
||||
pub username_is_not_customized: bool,
|
||||
pub email_address: String,
|
||||
pub email_confirmed: bool,
|
||||
pub is_without_password: bool,
|
||||
pub ip_address_creation: String,
|
||||
pub maybe_source: Option<UserSignupSource>,
|
||||
pub maybe_signup_method: Option<UserSignupMethod>,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub maybe_referral_url: Option<String>,
|
||||
pub is_temporary: bool,
|
||||
|
||||
// Subscription fields
|
||||
pub subscription_namespace: String,
|
||||
pub subscription_product_slug: String,
|
||||
pub maybe_stripe_subscription_id: Option<String>,
|
||||
pub maybe_stripe_customer_id: Option<String>,
|
||||
pub maybe_stripe_product_id: Option<String>,
|
||||
pub maybe_stripe_price_id: Option<String>,
|
||||
pub maybe_stripe_subscription_status: Option<String>,
|
||||
pub maybe_stripe_recurring_interval: Option<String>,
|
||||
pub maybe_stripe_invoice_is_paid: Option<bool>,
|
||||
pub maybe_cancel_at: Option<DateTime<Utc>>,
|
||||
pub maybe_canceled_at: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
pub struct ListSubscribingUsersBySignupDateArgs {
|
||||
pub maybe_id_cursor: Option<u64>,
|
||||
pub limit: u32,
|
||||
}
|
||||
|
||||
pub struct ListSubscribingUsersBySignupDateResult {
|
||||
pub users: Vec<ListSubscribingUsersBySignupDateRow>,
|
||||
pub next_cursor: Option<u64>,
|
||||
}
|
||||
|
||||
pub async fn list_subscribing_users_by_signup_date_for_moderation(
|
||||
args: ListSubscribingUsersBySignupDateArgs,
|
||||
mysql_pool: &MySqlPool,
|
||||
) -> AnyhowResult<ListSubscribingUsersBySignupDateResult> {
|
||||
// Fetch limit + 1 so we can detect whether there's a next page.
|
||||
let fetch_limit = (args.limit + 1) as i64;
|
||||
|
||||
// Use i64::MAX when no cursor so all rows are included.
|
||||
let id_cursor = args.maybe_id_cursor
|
||||
.map(|c| c as i64)
|
||||
.unwrap_or(i64::MAX);
|
||||
|
||||
let rows = sqlx::query_as!(
|
||||
ListSubscribingUsersBySignupDateRow,
|
||||
r#"
|
||||
SELECT
|
||||
u.id as `id: u64`,
|
||||
u.token as `token: tokens::tokens::users::UserToken`,
|
||||
u.username,
|
||||
u.display_name,
|
||||
u.username_is_not_customized as `username_is_not_customized: bool`,
|
||||
u.email_address,
|
||||
u.email_confirmed as `email_confirmed: bool`,
|
||||
u.is_without_password as `is_without_password: bool`,
|
||||
u.ip_address_creation,
|
||||
u.maybe_source as `maybe_source: enums::by_table::users::user_signup_source::UserSignupSource`,
|
||||
u.maybe_signup_method as `maybe_signup_method: enums::by_table::users::user_signup_method::UserSignupMethod`,
|
||||
u.created_at,
|
||||
u.maybe_referral_url,
|
||||
u.is_temporary as `is_temporary: bool`,
|
||||
us.subscription_namespace,
|
||||
us.subscription_product_slug,
|
||||
us.maybe_stripe_subscription_id,
|
||||
us.maybe_stripe_customer_id,
|
||||
us.maybe_stripe_product_id,
|
||||
us.maybe_stripe_price_id,
|
||||
us.maybe_stripe_subscription_status,
|
||||
us.maybe_stripe_recurring_interval,
|
||||
us.maybe_stripe_invoice_is_paid as `maybe_stripe_invoice_is_paid: bool`,
|
||||
us.maybe_cancel_at,
|
||||
us.maybe_canceled_at
|
||||
FROM users AS u
|
||||
INNER JOIN user_subscriptions AS us ON u.token = us.user_token
|
||||
WHERE
|
||||
u.id < ?
|
||||
AND u.user_deleted_at IS NULL
|
||||
AND u.mod_deleted_at IS NULL
|
||||
ORDER BY u.id DESC
|
||||
LIMIT ?
|
||||
"#,
|
||||
id_cursor,
|
||||
fetch_limit,
|
||||
)
|
||||
.fetch_all(mysql_pool)
|
||||
.await
|
||||
.map_err(|err| {
|
||||
warn!("list_subscribing_users_by_signup_date_for_moderation query error: {:?}", err);
|
||||
anyhow::anyhow!("query error")
|
||||
})?;
|
||||
|
||||
let has_next = rows.len() as u32 > args.limit;
|
||||
let users: Vec<ListSubscribingUsersBySignupDateRow> = rows.into_iter().take(args.limit as usize).collect();
|
||||
let next_cursor = if has_next {
|
||||
users.last().map(|u| u.id)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
Ok(ListSubscribingUsersBySignupDateResult {
|
||||
users,
|
||||
next_cursor,
|
||||
})
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
use chrono::{DateTime, Utc};
|
||||
use log::warn;
|
||||
use sqlx::MySqlPool;
|
||||
|
||||
use enums::by_table::users::user_signup_method::UserSignupMethod;
|
||||
use enums::by_table::users::user_signup_source::UserSignupSource;
|
||||
use errors::AnyhowResult;
|
||||
use tokens::tokens::users::UserToken;
|
||||
|
||||
pub struct ListUsersBySignupDateRow {
|
||||
pub id: u64,
|
||||
pub token: UserToken,
|
||||
pub username: String,
|
||||
pub display_name: String,
|
||||
pub username_is_not_customized: bool,
|
||||
pub email_address: String,
|
||||
pub email_confirmed: bool,
|
||||
pub is_without_password: bool,
|
||||
pub ip_address_creation: String,
|
||||
pub maybe_source: Option<UserSignupSource>,
|
||||
pub maybe_signup_method: Option<UserSignupMethod>,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub maybe_referral_url: Option<String>,
|
||||
pub is_temporary: bool,
|
||||
}
|
||||
|
||||
pub struct ListUsersBySignupDateArgs {
|
||||
pub maybe_id_cursor: Option<u64>,
|
||||
pub limit: u32,
|
||||
}
|
||||
|
||||
pub struct ListUsersBySignupDateResult {
|
||||
pub users: Vec<ListUsersBySignupDateRow>,
|
||||
pub next_cursor: Option<u64>,
|
||||
}
|
||||
|
||||
pub async fn list_users_by_signup_date_for_moderation(
|
||||
args: ListUsersBySignupDateArgs,
|
||||
mysql_pool: &MySqlPool,
|
||||
) -> AnyhowResult<ListUsersBySignupDateResult> {
|
||||
// Fetch limit + 1 so we can detect whether there's a next page.
|
||||
let fetch_limit = (args.limit + 1) as i64;
|
||||
|
||||
// Use i64::MAX when no cursor so all rows are included.
|
||||
let id_cursor = args.maybe_id_cursor
|
||||
.map(|c| c as i64)
|
||||
.unwrap_or(i64::MAX);
|
||||
|
||||
let rows = sqlx::query_as!(
|
||||
ListUsersBySignupDateRow,
|
||||
r#"
|
||||
SELECT
|
||||
u.id as `id: u64`,
|
||||
u.token as `token: tokens::tokens::users::UserToken`,
|
||||
u.username,
|
||||
u.display_name,
|
||||
u.username_is_not_customized as `username_is_not_customized: bool`,
|
||||
u.email_address,
|
||||
u.email_confirmed as `email_confirmed: bool`,
|
||||
u.is_without_password as `is_without_password: bool`,
|
||||
u.ip_address_creation,
|
||||
u.maybe_source as `maybe_source: enums::by_table::users::user_signup_source::UserSignupSource`,
|
||||
u.maybe_signup_method as `maybe_signup_method: enums::by_table::users::user_signup_method::UserSignupMethod`,
|
||||
u.created_at,
|
||||
u.maybe_referral_url,
|
||||
u.is_temporary as `is_temporary: bool`
|
||||
FROM users AS u
|
||||
WHERE
|
||||
u.id < ?
|
||||
AND u.user_deleted_at IS NULL
|
||||
AND u.mod_deleted_at IS NULL
|
||||
ORDER BY u.id DESC
|
||||
LIMIT ?
|
||||
"#,
|
||||
id_cursor,
|
||||
fetch_limit,
|
||||
)
|
||||
.fetch_all(mysql_pool)
|
||||
.await
|
||||
.map_err(|err| {
|
||||
warn!("list_users_by_signup_date_for_moderation query error: {:?}", err);
|
||||
anyhow::anyhow!("query error")
|
||||
})?;
|
||||
|
||||
let has_next = rows.len() as u32 > args.limit;
|
||||
let users: Vec<ListUsersBySignupDateRow> = rows.into_iter().take(args.limit as usize).collect();
|
||||
let next_cursor = if has_next {
|
||||
users.last().map(|u| u.id)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
Ok(ListUsersBySignupDateResult {
|
||||
users,
|
||||
next_cursor,
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
pub mod list_subscribing_users_by_signup_date_for_moderation;
|
||||
pub mod list_users_by_signup_date_for_moderation;
|
||||
@@ -1,4 +1,5 @@
|
||||
pub mod create;
|
||||
pub mod get;
|
||||
pub mod list;
|
||||
pub mod list_users_query_builder;
|
||||
pub mod update;
|
||||
@@ -278,6 +278,8 @@ use artcraft_api_defs::subscriptions::get_session_subscription::*;
|
||||
use artcraft_api_defs::media_file::list_batch_generated_media_files::*;
|
||||
// Handler modules with locally-defined types
|
||||
use crate::http_server::endpoints::moderation::info::moderator_token_info_handler::*;
|
||||
use artcraft_api_defs::moderation::user::list_subscribing_users_by_signup_date::*;
|
||||
use artcraft_api_defs::moderation::user::list_users_by_signup_date::*;
|
||||
use artcraft_api_defs::moderation::user::user_lookup::*;
|
||||
use artcraft_api_defs::moderation::user::user_lookup_by_stripe_customer_id::*;
|
||||
use artcraft_api_defs::moderation::jobs::user::list_user_jobs::*;
|
||||
@@ -466,6 +468,8 @@ use crate::http_server::endpoints::media_files::list::list_batch_generated_redux
|
||||
crate::http_server::endpoints::tts::enqueue_infer_f5_tts_handler::enqueue_infer_f5_tts_handler::enqueue_infer_f5_tts_handler,
|
||||
// Moderation
|
||||
crate::http_server::endpoints::moderation::info::moderator_token_info_handler::moderator_get_token_info_handler,
|
||||
crate::http_server::endpoints::moderation::user::moderator_list_subscribing_users_by_signup_date::moderator_list_subscribing_users_by_signup_date_handler,
|
||||
crate::http_server::endpoints::moderation::user::moderator_list_users_by_signup_date::moderator_list_users_by_signup_date_handler,
|
||||
crate::http_server::endpoints::moderation::user::moderator_user_lookup_handler::moderator_user_lookup_handler,
|
||||
crate::http_server::endpoints::moderation::user::moderator_user_lookup_by_stripe_customer_id_handler::moderator_user_lookup_by_stripe_customer_id_handler,
|
||||
crate::http_server::endpoints::moderation::jobs::user::list_user_jobs_handler::list_user_jobs_handler,
|
||||
@@ -657,6 +661,12 @@ use crate::http_server::endpoints::media_files::list::list_batch_generated_redux
|
||||
EditUserFeatureFlagsError,
|
||||
EditUserFeatureFlagsOption,
|
||||
EditUserFeatureFlagsRequest,
|
||||
ModeratorListSubscribingUsersBySignupDateRequest,
|
||||
ModeratorListSubscribingUsersBySignupDateResponse,
|
||||
ModeratorListSubscribingUsersBySignupDateEntry,
|
||||
ModeratorListUsersBySignupDateRequest,
|
||||
ModeratorListUsersBySignupDateResponse,
|
||||
ModeratorListUsersBySignupDateEntry,
|
||||
ModeratorUserLookupRequest,
|
||||
ModeratorUserLookupSuccessResponse,
|
||||
ModeratorUserLookupUserDetails,
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
pub mod moderator_list_subscribing_users_by_signup_date;
|
||||
pub mod moderator_list_users_by_signup_date;
|
||||
pub mod moderator_user_lookup_by_stripe_customer_id_handler;
|
||||
pub mod moderator_user_lookup_handler;
|
||||
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use actix_web::web::Json;
|
||||
use actix_web::{web, HttpRequest};
|
||||
use log::warn;
|
||||
|
||||
use artcraft_api_defs::moderation::user::list_subscribing_users_by_signup_date::{
|
||||
ModeratorListSubscribingUsersBySignupDateEntry,
|
||||
ModeratorListSubscribingUsersBySignupDateRequest,
|
||||
ModeratorListSubscribingUsersBySignupDateResponse,
|
||||
};
|
||||
use mysql_queries::queries::users::user::list::list_subscribing_users_by_signup_date_for_moderation::{
|
||||
list_subscribing_users_by_signup_date_for_moderation,
|
||||
ListSubscribingUsersBySignupDateArgs,
|
||||
};
|
||||
|
||||
use crate::http_server::common_responses::common_web_error::CommonWebError;
|
||||
use crate::http_server::web_utils::user_session::require_moderator::{require_moderator, UseDatabase};
|
||||
use crate::state::server_state::ServerState;
|
||||
|
||||
/// List subscribing users by signup date (descending), for moderators.
|
||||
#[utoipa::path(
|
||||
post,
|
||||
tag = "Moderation",
|
||||
path = "/v1/moderation/users/list_subscribers_by_signup_date",
|
||||
request_body = ModeratorListSubscribingUsersBySignupDateRequest,
|
||||
responses(
|
||||
(status = 200, description = "Success", body = ModeratorListSubscribingUsersBySignupDateResponse),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 500, description = "Server error"),
|
||||
),
|
||||
)]
|
||||
pub async fn moderator_list_subscribing_users_by_signup_date_handler(
|
||||
http_request: HttpRequest,
|
||||
request: Json<ModeratorListSubscribingUsersBySignupDateRequest>,
|
||||
server_state: web::Data<Arc<ServerState>>,
|
||||
) -> Result<Json<ModeratorListSubscribingUsersBySignupDateResponse>, CommonWebError> {
|
||||
|
||||
let _user_session = require_moderator(&http_request, &server_state, UseDatabase::GrabNewConnection)
|
||||
.await
|
||||
.map_err(|_| CommonWebError::NotAuthorized)?;
|
||||
|
||||
let result = list_subscribing_users_by_signup_date_for_moderation(
|
||||
ListSubscribingUsersBySignupDateArgs {
|
||||
maybe_id_cursor: request.id_cursor,
|
||||
limit: 100,
|
||||
},
|
||||
&server_state.mysql_pool,
|
||||
).await
|
||||
.map_err(|err| {
|
||||
warn!("moderator_list_subscribing_users_by_signup_date error: {:?}", err);
|
||||
CommonWebError::ServerError
|
||||
})?;
|
||||
|
||||
let users = result.users.into_iter().map(|u| ModeratorListSubscribingUsersBySignupDateEntry {
|
||||
id: u.id,
|
||||
token: u.token,
|
||||
username: u.username,
|
||||
display_name: u.display_name,
|
||||
username_is_not_customized: u.username_is_not_customized,
|
||||
email_address: u.email_address,
|
||||
email_confirmed: u.email_confirmed,
|
||||
is_without_password: u.is_without_password,
|
||||
ip_address_creation: u.ip_address_creation,
|
||||
maybe_source: u.maybe_source,
|
||||
maybe_signup_method: u.maybe_signup_method,
|
||||
created_at: u.created_at,
|
||||
maybe_referral_url: u.maybe_referral_url,
|
||||
is_temporary: u.is_temporary,
|
||||
subscription_namespace: u.subscription_namespace,
|
||||
subscription_product_slug: u.subscription_product_slug,
|
||||
maybe_stripe_subscription_id: u.maybe_stripe_subscription_id,
|
||||
maybe_stripe_customer_id: u.maybe_stripe_customer_id,
|
||||
maybe_stripe_product_id: u.maybe_stripe_product_id,
|
||||
maybe_stripe_price_id: u.maybe_stripe_price_id,
|
||||
maybe_stripe_subscription_status: u.maybe_stripe_subscription_status,
|
||||
maybe_stripe_recurring_interval: u.maybe_stripe_recurring_interval,
|
||||
maybe_stripe_invoice_is_paid: u.maybe_stripe_invoice_is_paid,
|
||||
maybe_cancel_at: u.maybe_cancel_at,
|
||||
maybe_canceled_at: u.maybe_canceled_at,
|
||||
}).collect();
|
||||
|
||||
Ok(Json(ModeratorListSubscribingUsersBySignupDateResponse {
|
||||
success: true,
|
||||
users,
|
||||
next_cursor: result.next_cursor,
|
||||
}))
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use actix_web::web::Json;
|
||||
use actix_web::{web, HttpRequest};
|
||||
use log::warn;
|
||||
|
||||
use artcraft_api_defs::moderation::user::list_users_by_signup_date::{
|
||||
ModeratorListUsersBySignupDateEntry,
|
||||
ModeratorListUsersBySignupDateRequest,
|
||||
ModeratorListUsersBySignupDateResponse,
|
||||
};
|
||||
use mysql_queries::queries::users::user::list::list_users_by_signup_date_for_moderation::{
|
||||
list_users_by_signup_date_for_moderation,
|
||||
ListUsersBySignupDateArgs,
|
||||
};
|
||||
|
||||
use crate::http_server::common_responses::common_web_error::CommonWebError;
|
||||
use crate::http_server::web_utils::user_session::require_moderator::{require_moderator, UseDatabase};
|
||||
use crate::state::server_state::ServerState;
|
||||
|
||||
/// List users by signup date (descending), for moderators.
|
||||
#[utoipa::path(
|
||||
post,
|
||||
tag = "Moderation",
|
||||
path = "/v1/moderation/users/list_all_by_signup_date",
|
||||
request_body = ModeratorListUsersBySignupDateRequest,
|
||||
responses(
|
||||
(status = 200, description = "Success", body = ModeratorListUsersBySignupDateResponse),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 500, description = "Server error"),
|
||||
),
|
||||
)]
|
||||
pub async fn moderator_list_users_by_signup_date_handler(
|
||||
http_request: HttpRequest,
|
||||
request: Json<ModeratorListUsersBySignupDateRequest>,
|
||||
server_state: web::Data<Arc<ServerState>>,
|
||||
) -> Result<Json<ModeratorListUsersBySignupDateResponse>, CommonWebError> {
|
||||
|
||||
let _user_session = require_moderator(&http_request, &server_state, UseDatabase::GrabNewConnection)
|
||||
.await
|
||||
.map_err(|_| CommonWebError::NotAuthorized)?;
|
||||
|
||||
let result = list_users_by_signup_date_for_moderation(
|
||||
ListUsersBySignupDateArgs {
|
||||
maybe_id_cursor: request.id_cursor,
|
||||
limit: 100,
|
||||
},
|
||||
&server_state.mysql_pool,
|
||||
).await
|
||||
.map_err(|err| {
|
||||
warn!("moderator_list_users_by_signup_date error: {:?}", err);
|
||||
CommonWebError::ServerError
|
||||
})?;
|
||||
|
||||
let users = result.users.into_iter().map(|u| ModeratorListUsersBySignupDateEntry {
|
||||
id: u.id,
|
||||
token: u.token,
|
||||
username: u.username,
|
||||
display_name: u.display_name,
|
||||
username_is_not_customized: u.username_is_not_customized,
|
||||
email_address: u.email_address,
|
||||
email_confirmed: u.email_confirmed,
|
||||
is_without_password: u.is_without_password,
|
||||
ip_address_creation: u.ip_address_creation,
|
||||
maybe_source: u.maybe_source,
|
||||
maybe_signup_method: u.maybe_signup_method,
|
||||
created_at: u.created_at,
|
||||
maybe_referral_url: u.maybe_referral_url,
|
||||
is_temporary: u.is_temporary,
|
||||
}).collect();
|
||||
|
||||
Ok(Json(ModeratorListUsersBySignupDateResponse {
|
||||
success: true,
|
||||
users,
|
||||
next_cursor: result.next_cursor,
|
||||
}))
|
||||
}
|
||||
+10
@@ -31,6 +31,8 @@ use crate::http_server::endpoints::moderation::jobs::get_w2l_inference_queue_cou
|
||||
use crate::http_server::endpoints::moderation::jobs::kill_tts_inference_jobs::kill_tts_inference_jobs_handler;
|
||||
use crate::http_server::endpoints::moderation::user_bans::ban_user::ban_user_handler;
|
||||
use crate::http_server::endpoints::moderation::user_bans::list_banned_users::list_banned_users_handler;
|
||||
use crate::http_server::endpoints::moderation::user::moderator_list_subscribing_users_by_signup_date::moderator_list_subscribing_users_by_signup_date_handler;
|
||||
use crate::http_server::endpoints::moderation::user::moderator_list_users_by_signup_date::moderator_list_users_by_signup_date_handler;
|
||||
use crate::http_server::endpoints::moderation::user::moderator_user_lookup_by_stripe_customer_id_handler::moderator_user_lookup_by_stripe_customer_id_handler;
|
||||
use crate::http_server::endpoints::moderation::user::moderator_user_lookup_handler::moderator_user_lookup_handler;
|
||||
use crate::http_server::endpoints::moderation::user_feature_flags::edit_user_feature_flags_handler::edit_user_feature_flags_handler;
|
||||
@@ -60,6 +62,14 @@ pub fn add_moderator_routes<T, B> (app: App<T>) -> App<T>
|
||||
.route(web::post().to(moderator_user_lookup_by_stripe_customer_id_handler))
|
||||
.route(web::head().to(|| HttpResponse::Ok()))
|
||||
)
|
||||
.service(web::resource("/list_all_by_signup_date")
|
||||
.route(web::post().to(moderator_list_users_by_signup_date_handler))
|
||||
.route(web::head().to(|| HttpResponse::Ok()))
|
||||
)
|
||||
.service(web::resource("/list_subscribers_by_signup_date")
|
||||
.route(web::post().to(moderator_list_subscribing_users_by_signup_date_handler))
|
||||
.route(web::head().to(|| HttpResponse::Ok()))
|
||||
)
|
||||
)
|
||||
.service(web::scope("/jobs")
|
||||
.service(web::resource("/user/{user_token}/list")
|
||||
|
||||
Reference in New Issue
Block a user