Backend change visitor country to country code alpha2

pull/3/head
TZGyn 2 years ago
parent 606e68d129
commit 5ea9c8bdc4
Signed by: TZGyn
GPG Key ID: 122EAF77AE81FD4A

@ -65,7 +65,7 @@ app.get(
const visitor_data = { const visitor_data = {
shortener_id: shortener[0].id, shortener_id: shortener[0].id,
country: geolocation.data.location.country.name as string, country_code: geolocation.data.location.country.alpha2 as string,
} }
await db.insertInto('visitor').values(visitor_data).execute() await db.insertInto('visitor').values(visitor_data).execute()
@ -92,7 +92,7 @@ app.get('/link/:shortenerCode', async ({ params: { shortenerCode } }) => {
.selectFrom('visitor') .selectFrom('visitor')
.select([ .select([
'visitor.created_at as visited_at', 'visitor.created_at as visited_at',
'visitor.country', 'visitor.country_code',
]) ])
.whereRef('visitor.shortener_id', '=', 'shortener.id') .whereRef('visitor.shortener_id', '=', 'shortener.id')
).as('visitors'), ).as('visitors'),

@ -25,7 +25,7 @@ export type ShortenerUpdate = Updateable<ShortenerTable>
export interface VisitorTable { export interface VisitorTable {
id: Generated<number> id: Generated<number>
shortener_id: number shortener_id: number
country: string country_code: string
created_at: ColumnType<Date, string | undefined, never> created_at: ColumnType<Date, string | undefined, never>
} }

Loading…
Cancel
Save