Fix long statuses. Not perfect but good for now

This commit is contained in:
2024-09-24 11:04:34 -05:00
parent 744328c156
commit aab4efbb00
4 changed files with 56 additions and 55 deletions

View File

@@ -128,45 +128,3 @@ export const get_history = async (user_id: number, page: number, perPage: number
}
};
};
//export const getHistory =
//async (page: number, perPage: number): Promise<PaginatedHistory> => {
//const offset = (page - 1) * perPage;
//const historyQuery = sql`
//SELECT u.name, h.status, h.updatedAt
//FROM history h
//JOIN users u ON h.user_id = u.id
//ORDER BY h.id DESC
//LIMIT ${perPage} OFFSET ${offset}
//`;
//const countQuery = sql`
//SELECT COUNT(*) AS total_count
//FROM history
//`;
//const [historyResults, countResults] = await Promise.all([
//db.execute(historyQuery),
//db.execute(countQuery),
//]);
//// Safely cast results
//const historyRows = historyResults[0] as unknown as
//{ name: string, status: string, updatedAt: Date }[];
//const countRow = countResults[0] as unknown as { total_count: number }[];
//const totalCount = countRow[0]?.total_count ?? 0;
//const totalPages = Math.ceil(totalCount / perPage);
//// Format and map results
//const formattedResults: HistoryEntry[] = historyRows.map(row => ({
//name: row.name,
//status: row.status,
//updatedAt: new Date(row.updatedAt),
//}));
//return {
//data: formattedResults,
//meta: {
//current_page: page,
//per_page: perPage,
//total_pages: totalPages,
//total_count: totalCount,
//}
//};
//};