mirror of https://github.com/synctv-org/synctv
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
181 lines
6.1 KiB
JSON
181 lines
6.1 KiB
JSON
{
|
|
"db_name": "PostgreSQL",
|
|
"query": "\n SELECT u.id AS \"id!: UserId\",\n u.username AS \"username!\",\n u.role AS \"role!: crate::models::UserRole\",\n u.avatar_file_reference_id,\n CASE\n WHEN active_ban.user_id IS NULL THEN 1::SMALLINT\n ELSE 2::SMALLINT\n END AS \"status!: crate::models::UserStatus\",\n (active_ban.user_id IS NOT NULL) AS \"is_banned!\",\n active_ban.starts_at AS \"banned_at?\",\n active_ban.banned_by AS \"banned_by?: UserId\",\n active_ban.reason AS banned_reason,\n u.signup_method AS \"signup_method!: crate::models::SignupMethod\",\n u.created_at AS \"created_at!\",\n u.updated_at AS \"updated_at!\",\n u.version AS \"version!\",\n u.deleted_at\n FROM room_members rm\n JOIN users u ON u.id = rm.user_id AND u.deleted_at IS NULL\n LEFT JOIN LATERAL (\n SELECT ub.user_id,\n ub.starts_at,\n ub.banned_by,\n ub.reason\n FROM user_bans ub\n WHERE ub.user_id = u.id\n AND ub.revoked_at IS NULL\n AND (ub.ends_at IS NULL OR ub.ends_at > CURRENT_TIMESTAMP)\n ORDER BY ub.starts_at DESC\n LIMIT 1\n ) active_ban ON TRUE\n LEFT JOIN chat_read_states crs\n ON crs.room_id = rm.room_id\n AND crs.user_id = rm.user_id\n WHERE rm.room_id = $1\n AND ($2::BIGINT IS NULL OR rm.user_id <> $2)\n AND NOT COALESCE((\n (crs.last_read_event_sequence IS NOT NULL\n AND $3::BIGINT IS NOT NULL\n AND crs.last_read_event_sequence >= $3)\n OR (crs.last_read_message_created_at IS NOT NULL\n AND crs.last_read_message_id IS NOT NULL\n AND (crs.last_read_message_created_at, crs.last_read_message_id)\n > ($4, $5))\n OR ($3::BIGINT IS NULL\n AND crs.last_read_message_created_at IS NOT NULL\n AND crs.last_read_message_id IS NOT NULL\n AND (crs.last_read_message_created_at, crs.last_read_message_id)\n = ($4, $5))\n ), FALSE)\n ORDER BY u.username ASC, u.id ASC\n LIMIT $6 OFFSET $7\n ",
|
|
"describe": {
|
|
"columns": [
|
|
{
|
|
"ordinal": 0,
|
|
"name": "id!: UserId",
|
|
"type_info": "Int8",
|
|
"origin": {
|
|
"Table": {
|
|
"table": "users",
|
|
"name": "id"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"ordinal": 1,
|
|
"name": "username!",
|
|
"type_info": "Varchar",
|
|
"origin": {
|
|
"Table": {
|
|
"table": "users",
|
|
"name": "username"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"ordinal": 2,
|
|
"name": "role!: crate::models::UserRole",
|
|
"type_info": "Int2",
|
|
"origin": {
|
|
"Table": {
|
|
"table": "users",
|
|
"name": "role"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"ordinal": 3,
|
|
"name": "avatar_file_reference_id",
|
|
"type_info": "Int8",
|
|
"origin": {
|
|
"Table": {
|
|
"table": "users",
|
|
"name": "avatar_file_reference_id"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"ordinal": 4,
|
|
"name": "status!: crate::models::UserStatus",
|
|
"type_info": "Int2",
|
|
"origin": "Expression"
|
|
},
|
|
{
|
|
"ordinal": 5,
|
|
"name": "is_banned!",
|
|
"type_info": "Bool",
|
|
"origin": "Expression"
|
|
},
|
|
{
|
|
"ordinal": 6,
|
|
"name": "banned_at?",
|
|
"type_info": "Timestamptz",
|
|
"origin": {
|
|
"Table": {
|
|
"table": "user_bans",
|
|
"name": "starts_at"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"ordinal": 7,
|
|
"name": "banned_by?: UserId",
|
|
"type_info": "Int8",
|
|
"origin": {
|
|
"Table": {
|
|
"table": "user_bans",
|
|
"name": "banned_by"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"ordinal": 8,
|
|
"name": "banned_reason",
|
|
"type_info": "Text",
|
|
"origin": {
|
|
"Table": {
|
|
"table": "user_bans",
|
|
"name": "reason"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"ordinal": 9,
|
|
"name": "signup_method!: crate::models::SignupMethod",
|
|
"type_info": "Int2",
|
|
"origin": {
|
|
"Table": {
|
|
"table": "users",
|
|
"name": "signup_method"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"ordinal": 10,
|
|
"name": "created_at!",
|
|
"type_info": "Timestamptz",
|
|
"origin": {
|
|
"Table": {
|
|
"table": "users",
|
|
"name": "created_at"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"ordinal": 11,
|
|
"name": "updated_at!",
|
|
"type_info": "Timestamptz",
|
|
"origin": {
|
|
"Table": {
|
|
"table": "users",
|
|
"name": "updated_at"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"ordinal": 12,
|
|
"name": "version!",
|
|
"type_info": "Int4",
|
|
"origin": {
|
|
"Table": {
|
|
"table": "users",
|
|
"name": "version"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"ordinal": 13,
|
|
"name": "deleted_at",
|
|
"type_info": "Timestamptz",
|
|
"origin": {
|
|
"Table": {
|
|
"table": "users",
|
|
"name": "deleted_at"
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"parameters": {
|
|
"Left": [
|
|
"Int8",
|
|
"Int8",
|
|
"Int8",
|
|
"Timestamptz",
|
|
"Int8",
|
|
"Int8",
|
|
"Int8"
|
|
]
|
|
},
|
|
"nullable": [
|
|
false,
|
|
false,
|
|
false,
|
|
true,
|
|
null,
|
|
null,
|
|
false,
|
|
true,
|
|
true,
|
|
false,
|
|
false,
|
|
false,
|
|
false,
|
|
true
|
|
]
|
|
},
|
|
"hash": "39bf8cd6c724bb88fa743f14e722cc6bf0db9ae2844c83fedd6ebc036ef1e08b"
|
|
}
|