Skip to content

Commit

Permalink
Adding geolocation in response. Class types Station and StationRespon…
Browse files Browse the repository at this point in the history
…se modified with optional fields geo_lat and geo_long
  • Loading branch information
antoniovlx committed Mar 4, 2022
1 parent 649f476 commit 96a2b96
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export type StationResponse = {
lastcheckoktime: string
clicktimestamp: string
clickcount: number
clicktrend: number
clicktrend: number,
geo_lat?: number
geo_long?: number
}

/**
Expand Down Expand Up @@ -99,7 +101,9 @@ export type Station = {
lastLocalCheckTime: Date
clickTimestamp: Date
clickCount: number
clickTrend: number
clickTrend: number,
geo_lat?: number
geo_long?: number
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/radioBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ export class RadioBrowserApi {
lastLocalCheckTime: new Date(response.lastlocalchecktime),
language: response.language.split(','),
lastCheckTime: new Date(response.lastchecktime),
geo_lat: response.geo_lat !== null ? response.geo_lat: undefined,
geo_long: response.geo_long !== null ? response.geo_long: undefined,
tags: [...new Set(response.tags.split(','))].filter(
(tag) => tag.length > 0 && tag.length < 10
) // drop duplicates and tags over 10 characters
Expand Down
4 changes: 3 additions & 1 deletion tests/utils/mockStation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export function getMockResponse(): StationResponse {
lastlocalchecktime: '2020-10-27 06:04:51',
clicktimestamp: '2020-10-25 18:33:05',
clickcount: 14,
clicktrend: -1
clicktrend: -1,
geo_lat: 47.70441105302798,
geo_long: 14.795494079589846,
}
}

Expand Down

0 comments on commit 96a2b96

Please sign in to comment.