|
|
@ -42,6 +42,14 @@ export class LendingStationAPI extends DataSource {
|
|
|
|
.getOne().catch(() => { return null; });
|
|
|
|
.getOne().catch(() => { return null; });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async lendingStationByTimeFrameId (id: number) {
|
|
|
|
|
|
|
|
await this.connection.getRepository(TimeFrame)
|
|
|
|
|
|
|
|
.createQueryBuilder('timeframe')
|
|
|
|
|
|
|
|
.relation(TimeFrame, 'lendingStation')
|
|
|
|
|
|
|
|
.of(id)
|
|
|
|
|
|
|
|
.loadOne();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async timeFrames (offset: number, limit: number) {
|
|
|
|
async timeFrames (offset: number, limit: number) {
|
|
|
|
return await this.connection.getRepository(TimeFrame)
|
|
|
|
return await this.connection.getRepository(TimeFrame)
|
|
|
|
.createQueryBuilder('timeframe')
|
|
|
|
.createQueryBuilder('timeframe')
|
|
|
@ -127,28 +135,32 @@ export class LendingStationAPI extends DataSource {
|
|
|
|
|
|
|
|
|
|
|
|
async createTimeFrame (timeFrame: any) {
|
|
|
|
async createTimeFrame (timeFrame: any) {
|
|
|
|
let inserts: any;
|
|
|
|
let inserts: any;
|
|
|
|
await this.connection.transaction(async (entityManager: EntityManager) => {
|
|
|
|
try {
|
|
|
|
if (timeFrame.to === undefined) {
|
|
|
|
await this.connection.transaction(async (entityManager: EntityManager) => {
|
|
|
|
timeFrame.to = '';
|
|
|
|
if (timeFrame.to === undefined) {
|
|
|
|
}
|
|
|
|
timeFrame.to = '';
|
|
|
|
timeFrame.dateRange = '[' + timeFrame.from + ',' + timeFrame.to + ')';
|
|
|
|
}
|
|
|
|
inserts = await entityManager.getRepository(TimeFrame)
|
|
|
|
timeFrame.dateRange = '[' + timeFrame.from + ',' + timeFrame.to + ')';
|
|
|
|
.createQueryBuilder('timeframe')
|
|
|
|
inserts = await entityManager.getRepository(TimeFrame)
|
|
|
|
.insert()
|
|
|
|
.createQueryBuilder('timeframe')
|
|
|
|
.returning('*')
|
|
|
|
.insert()
|
|
|
|
.values([timeFrame])
|
|
|
|
.returning('*')
|
|
|
|
.execute();
|
|
|
|
.values([timeFrame])
|
|
|
|
await entityManager.getRepository(TimeFrame)
|
|
|
|
.execute();
|
|
|
|
.createQueryBuilder()
|
|
|
|
await entityManager.getRepository(TimeFrame)
|
|
|
|
.relation(TimeFrame, 'cargoBike')
|
|
|
|
.createQueryBuilder()
|
|
|
|
.of(inserts.identifiers[0].id)
|
|
|
|
.relation(TimeFrame, 'cargoBike')
|
|
|
|
.set(timeFrame.cargoBikeId);
|
|
|
|
.of(inserts.identifiers[0].id)
|
|
|
|
await entityManager.getRepository(TimeFrame)
|
|
|
|
.set(timeFrame.cargoBikeId);
|
|
|
|
.createQueryBuilder()
|
|
|
|
await entityManager.getRepository(TimeFrame)
|
|
|
|
.relation(TimeFrame, 'lendingStation')
|
|
|
|
.createQueryBuilder()
|
|
|
|
.of(inserts.identifiers[0].id)
|
|
|
|
.relation(TimeFrame, 'lendingStation')
|
|
|
|
.set(timeFrame.lendingStationId);
|
|
|
|
.of(inserts.identifiers[0].id)
|
|
|
|
});
|
|
|
|
.set(timeFrame.lendingStationId);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
return new GraphQLError('Transaction could not be completed');
|
|
|
|
|
|
|
|
}
|
|
|
|
inserts.generatedMaps[0].id = inserts.identifiers[0].id;
|
|
|
|
inserts.generatedMaps[0].id = inserts.identifiers[0].id;
|
|
|
|
return inserts.generatedMaps[0];
|
|
|
|
return inserts.generatedMaps[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|