@@ -84,9 +84,9 @@ export async function getApiLogs(
8484 'request_body' ,
8585 'response_body' ,
8686 'error_message' ,
87- 'timestamp ' ,
87+ 'created_at ' ,
8888 ] )
89- . orderBy ( 'timestamp ' , 'desc' ) ;
89+ . orderBy ( 'created_at ' , 'desc' ) ;
9090
9191 if ( filters . userId ) {
9292 query = query . where ( ( q ) =>
@@ -110,11 +110,11 @@ export async function getApiLogs(
110110 }
111111
112112 if ( filters . dateFrom ) {
113- query = query . where ( 'timestamp ' , '>=' , new Date ( filters . dateFrom ) ) ;
113+ query = query . where ( 'created_at ' , '>=' , new Date ( filters . dateFrom ) ) ;
114114 }
115115
116116 if ( filters . dateTo ) {
117- query = query . where ( 'timestamp ' , '<=' , new Date ( filters . dateTo ) ) ;
117+ query = query . where ( 'created_at ' , '<=' , new Date ( filters . dateTo ) ) ;
118118 }
119119
120120 if ( filters . search ) {
@@ -154,14 +154,14 @@ export async function getApiLogs(
154154 }
155155 if ( filters . dateFrom ) {
156156 countQuery = countQuery . where (
157- 'timestamp ' ,
157+ 'created_at ' ,
158158 '>=' ,
159159 new Date ( filters . dateFrom )
160160 ) ;
161161 }
162162 if ( filters . dateTo ) {
163163 countQuery = countQuery . where (
164- 'timestamp ' ,
164+ 'created_at ' ,
165165 '<=' ,
166166 new Date ( filters . dateTo )
167167 ) ;
@@ -242,7 +242,7 @@ export async function getApiLogStats(days: number = 7): Promise<ApiLogStats> {
242242 'errorCount'
243243 ) ,
244244 ] )
245- . where ( 'timestamp ' , '>=' , cutoffDate )
245+ . where ( 'created_at ' , '>=' , cutoffDate )
246246 . executeTakeFirst ( ) ;
247247
248248 const totalRequests = Number ( totalStatsResult ?. totalRequests || 0 ) ;
@@ -261,7 +261,7 @@ export async function getApiLogStats(days: number = 7): Promise<ApiLogStats> {
261261 sql < number > `count(*)` . as ( 'count' ) ,
262262 sql < number > `avg(response_time)` . as ( 'avgResponseTime' ) ,
263263 ] )
264- . where ( 'timestamp ' , '>=' , cutoffDate )
264+ . where ( 'created_at ' , '>=' , cutoffDate )
265265 . groupBy ( 'path' )
266266 . orderBy ( 'count' , 'desc' )
267267 . limit ( 10 )
@@ -271,7 +271,7 @@ export async function getApiLogStats(days: number = 7): Promise<ApiLogStats> {
271271 const statusCodeDistribution = await mainDb
272272 . selectFrom ( 'api_logs' )
273273 . select ( [ 'status_code' , sql < number > `count(*)` . as ( 'count' ) ] )
274- . where ( 'timestamp ' , '>=' , cutoffDate )
274+ . where ( 'created_at ' , '>=' , cutoffDate )
275275 . groupBy ( 'status_code' )
276276 . orderBy ( 'count' , 'desc' )
277277 . execute ( ) ;
@@ -280,15 +280,15 @@ export async function getApiLogStats(days: number = 7): Promise<ApiLogStats> {
280280 const dailyStats = await mainDb
281281 . selectFrom ( 'api_logs' )
282282 . select ( [
283- sql < string > `date(timestamp )` . as ( 'date' ) ,
283+ sql < string > `date(created_at )` . as ( 'date' ) ,
284284 sql < number > `count(*)` . as ( 'requestCount' ) ,
285285 sql < number > `count(case when status_code >= 400 then 1 end)` . as (
286286 'errorCount'
287287 ) ,
288288 sql < number > `avg(response_time)` . as ( 'avgResponseTime' ) ,
289289 ] )
290- . where ( 'timestamp ' , '>=' , cutoffDate )
291- . groupBy ( sql `date(timestamp )` )
290+ . where ( 'created_at ' , '>=' , cutoffDate )
291+ . groupBy ( sql `date(created_at )` )
292292 . orderBy ( 'date' , 'desc' )
293293 . execute ( ) ;
294294
@@ -348,7 +348,7 @@ export async function getApiLogStatsLast24Hours(): Promise<
348348 const hourlyStats = await mainDb
349349 . selectFrom ( 'api_logs' )
350350 . select ( [
351- sql < string > `date_trunc('hour', timestamp )` . as ( 'hour' ) ,
351+ sql < string > `date_trunc('hour', created_at )` . as ( 'hour' ) ,
352352 sql < number > `count(case when status_code >= 200 and status_code < 300 then 1 end)` . as (
353353 'successful'
354354 ) ,
@@ -362,8 +362,8 @@ export async function getApiLogStatsLast24Hours(): Promise<
362362 'other'
363363 ) ,
364364 ] )
365- . where ( 'timestamp ' , '>=' , cutoffDate )
366- . groupBy ( sql `date_trunc('hour', timestamp )` )
365+ . where ( 'created_at ' , '>=' , cutoffDate )
366+ . groupBy ( sql `date_trunc('hour', created_at )` )
367367 . orderBy ( 'hour' , 'asc' )
368368 . execute ( ) ;
369369
0 commit comments