Skip to content

Commit

Permalink
chore: vrr Occupancy (#503)
Browse files Browse the repository at this point in the history
* chore: change vrr Occupancy source url

* chore: remove deprecated API
  • Loading branch information
marudor authored Jul 10, 2021
1 parent c548d13 commit 1024421
Show file tree
Hide file tree
Showing 29 changed files with 29 additions and 10,254 deletions.
1 change: 0 additions & 1 deletion .envrc.examle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export OPENDATA_AUTH_KEY=
export LOGGLY_TOKEN=
export ENVIRONMENT=
export BUSINESS_HUB_STOP_PLACES_KEY=
export BUSINESS_HUB_NEWS_KEY=
export REDIS_HOST=
export REDIS_PORT=
export REDIS_PASSWORD=
Expand Down
5 changes: 0 additions & 5 deletions config/_common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ baseEnv:
secretKeyRef:
name: bahnhofs-abfahrten-config
key: business_hub_stop_places_key
- name: BUSINESS_HUB_NEWS_KEY
valueFrom:
secretKeyRef:
name: bahnhofs-abfahrten-config
key: business_hub_news_key
- name: HIM_MAX_FETCH
valueFrom:
secretKeyRef:
Expand Down
3 changes: 1 addition & 2 deletions packages/business-hub/risStations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ export async function byPosition(
export async function platforms(evaNumber: string): Promise<Platform[]> {
try {
const result = (
await request.get<Platforms>(`/ris-stations/v1/stop-places/platforms`, {
await request.get<Platforms>(`/ris-stations/v1/platforms/${evaNumber}`, {
params: {
evaNumber,
includeSubPlatforms: true,
includeOperational: true,
includeAccessibility: true,
Expand Down
77 changes: 0 additions & 77 deletions packages/business-hub/station.ts
Original file line number Diff line number Diff line change
@@ -1,84 +1,7 @@
import { formatISO } from 'date-fns';
import { request } from './request';
import type {
APIResult,
BusinessHubCoordinates,
BusinessHubStation,
DetailBusinessHubStation,
DetailsApiResult,
StopPlace,
} from 'business-hub/types/StopPlaces';
import type { OccupancyResponse } from 'business-hub/types/Occupancy';

const transformBusinessHubStation = (
businessHubStation: Pick<StopPlace, 'name' | 'identifiers' | 'location'>,
): BusinessHubStation => ({
title: businessHubStation.name,
id: businessHubStation.identifiers.find((i) => i.type === 'EVA')?.value || '',
location: businessHubStation.location,
ds100: businessHubStation.identifiers.find((i) => i.type === 'RIL100')?.value,
stada: businessHubStation.identifiers.find((i) => i.type === 'STADA')?.value,
globalId: businessHubStation.identifiers.find((i) => i.type === 'GLOBAL_ID')
?.value,
});
function filterApiResult(result: APIResult) {
return (
result?._embedded?.stopPlaceList
?.map(transformBusinessHubStation)
.filter((s) => s.id && s.ds100) ?? []
);
}
export async function stationSearch(
searchTerm?: string,
): Promise<BusinessHubStation[]> {
if (!searchTerm) return [];
const result = (
await request.get<APIResult>('/public-transport-stations/v1/stop-places', {
params: {
name: searchTerm,
},
})
).data;

return filterApiResult(result);
}

export async function geoSearch(
coordinates: BusinessHubCoordinates,
radius = 3000,
): Promise<BusinessHubStation[]> {
const result = (
await request.get<APIResult>('/public-transport-stations/v1/stop-places', {
params: {
...coordinates,
radius,
},
})
).data;

return filterApiResult(result);
}

export const stationDetails = async (
evaId: string,
): Promise<DetailBusinessHubStation> => {
const detailsResult = (
await request.get<DetailsApiResult>(
`/public-transport-stations/v1/stop-places/${evaId}`,
)
).data;

const { _embedded, _links, name, ...relevantDetails } = detailsResult;

const businessHubStation = transformBusinessHubStation(detailsResult);

return {
...businessHubStation,
...relevantDetails,
tripleSCenter: _embedded?.tripleSCenter,
};
};

export const stationOccupancy = async (
evaId: string,
date: Date,
Expand Down
47 changes: 0 additions & 47 deletions packages/business-hub/types/News.ts

This file was deleted.

176 changes: 0 additions & 176 deletions packages/business-hub/types/StopPlaces.ts

This file was deleted.

Loading

0 comments on commit 1024421

Please sign in to comment.