style: clean up code formatting and remove trailing whitespace
refactor: reorganize imports and fix type imports
This commit is contained in:
1 parent
d3704602fd
commit
47c04de6fe
232 files changed
+7140
-4798
No files matched your search
+17
-14
@@ -37,7 +37,7 @@ export interface ServerStats {
|
||||
*/
|
||||
export async function getAllServers(): Promise<Server[]> {
|
||||
const result = await query<Server>(
|
||||
`SELECT * FROM servers ORDER BY server_name ASC`
|
||||
`SELECT * FROM servers ORDER BY server_name ASC`,
|
||||
);
|
||||
return result.rows;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ export async function getAllServers(): Promise<Server[]> {
|
||||
*/
|
||||
export async function getActiveServers(): Promise<Server[]> {
|
||||
const result = await query<Server>(
|
||||
`SELECT * FROM servers WHERE is_active = TRUE ORDER BY server_name ASC`
|
||||
`SELECT * FROM servers WHERE is_active = TRUE ORDER BY server_name ASC`,
|
||||
);
|
||||
return result.rows;
|
||||
}
|
||||
@@ -55,10 +55,12 @@ export async function getActiveServers(): Promise<Server[]> {
|
||||
/**
|
||||
* Busca servidor por nome
|
||||
*/
|
||||
export async function getServerByName(serverName: string): Promise<Server | null> {
|
||||
export async function getServerByName(
|
||||
serverName: string,
|
||||
): Promise<Server | null> {
|
||||
const result = await query<Server>(
|
||||
`SELECT * FROM servers WHERE server_name = $1`,
|
||||
[serverName]
|
||||
[serverName],
|
||||
);
|
||||
return result.rows[0] || null;
|
||||
}
|
||||
@@ -69,7 +71,7 @@ export async function getServerByName(serverName: string): Promise<Server | null
|
||||
export async function getServerById(serverId: number): Promise<Server | null> {
|
||||
const result = await query<Server>(
|
||||
`SELECT * FROM servers WHERE server_id = $1`,
|
||||
[serverId]
|
||||
[serverId],
|
||||
);
|
||||
return result.rows[0] || null;
|
||||
}
|
||||
@@ -80,9 +82,9 @@ export async function getServerById(serverId: number): Promise<Server | null> {
|
||||
export async function isServerActive(serverName: string): Promise<boolean> {
|
||||
const result = await query<{ count: string }>(
|
||||
`SELECT COUNT(*) as count FROM servers WHERE server_name = $1 AND is_active = TRUE`,
|
||||
[serverName]
|
||||
[serverName],
|
||||
);
|
||||
return parseInt(result.rows[0].count) > 0;
|
||||
return parseInt(result.rows[0].count, 10) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,7 +98,7 @@ export async function incrementServerStats(
|
||||
total_subscribers: number;
|
||||
total_transactions: number;
|
||||
total_volume: number;
|
||||
}>
|
||||
}>,
|
||||
): Promise<void> {
|
||||
const updates: string[] = [];
|
||||
const values: any[] = [];
|
||||
@@ -133,7 +135,7 @@ export async function incrementServerStats(
|
||||
|
||||
await query(
|
||||
`UPDATE servers SET ${updates.join(", ")} WHERE server_name = $${paramIndex}`,
|
||||
values
|
||||
values,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -142,7 +144,7 @@ export async function incrementServerStats(
|
||||
*/
|
||||
export async function updateServerStats(
|
||||
serverName: string,
|
||||
stats: ServerStats
|
||||
stats: ServerStats,
|
||||
): Promise<void> {
|
||||
const updates: string[] = [];
|
||||
const values: any[] = [];
|
||||
@@ -185,14 +187,16 @@ export async function updateServerStats(
|
||||
|
||||
await query(
|
||||
`UPDATE servers SET ${updates.join(", ")} WHERE server_name = $${paramIndex}`,
|
||||
values
|
||||
values,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Incrementa total_users de múltiplos servidores
|
||||
*/
|
||||
export async function incrementUsersForServers(serverNames: string[]): Promise<void> {
|
||||
export async function incrementUsersForServers(
|
||||
serverNames: string[],
|
||||
): Promise<void> {
|
||||
if (serverNames.length === 0) {
|
||||
return;
|
||||
}
|
||||
@@ -202,7 +206,6 @@ export async function incrementUsersForServers(serverNames: string[]): Promise<v
|
||||
SET total_users = total_users + 1,
|
||||
last_activity_at = CURRENT_TIMESTAMP
|
||||
WHERE server_name = ANY($1::text[])`,
|
||||
[serverNames]
|
||||
[serverNames],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user