datasource/*: code a little clean up

pull/14/head
leonnicolas 4 years ago
parent 45a7fa6ec7
commit a67c0ff659
No known key found for this signature in database
GPG Key ID: 088D0743E2B65C07

@ -134,7 +134,6 @@ export class CargoBikeAPI extends DataSource {
*/ */
async createCargoBike ({ cargoBike }: { cargoBike: any }) { async createCargoBike ({ cargoBike }: { cargoBike: any }) {
let inserts: any; let inserts: any;
try {
await this.connection.transaction(async (entityManager:any) => { await this.connection.transaction(async (entityManager:any) => {
inserts = await entityManager.getRepository(CargoBike) inserts = await entityManager.getRepository(CargoBike)
.createQueryBuilder('cargobike') .createQueryBuilder('cargobike')
@ -153,10 +152,6 @@ export class CargoBikeAPI extends DataSource {
.of(inserts.identifiers[0].id) .of(inserts.identifiers[0].id)
.add(cargoBike.equipmentTypeIds); .add(cargoBike.equipmentTypeIds);
}); });
} catch (e: any) {
console.log(e);
return new GraphQLError('Transaction could not be completed');
}
const newbike = inserts.generatedMaps[0]; const newbike = inserts.generatedMaps[0];
newbike.id = inserts.identifiers[0].id; newbike.id = inserts.identifiers[0].id;
return newbike; return newbike;

@ -105,7 +105,6 @@ export class ContactInformationAPI extends DataSource {
.select() .select()
.where('ci."personId" = :id', { id: id }) .where('ci."personId" = :id', { id: id })
.getMany(); .getMany();
console.log(res);
return res; return res;
} }

@ -176,7 +176,6 @@ export class LendingStationAPI extends DataSource {
.where('timeframe."cargoBikeId" = :id', { id: timeFrame.cargoBikeId }) .where('timeframe."cargoBikeId" = :id', { id: timeFrame.cargoBikeId })
.andWhere('timeframe."dateRange" && :tr', { tr: timeFrame.dateRange }) .andWhere('timeframe."dateRange" && :tr', { tr: timeFrame.dateRange })
.getMany(); .getMany();
console.log(overlapping);
if (overlapping.length !== 0) { if (overlapping.length !== 0) {
throw new UserInputError('TimeFrames with ids: ' + overlapping.map((e) => { return e.id + ', '; }) + 'are overlapping'); throw new UserInputError('TimeFrames with ids: ' + overlapping.map((e) => { return e.id + ', '; }) + 'are overlapping');
} }
@ -198,7 +197,6 @@ export class LendingStationAPI extends DataSource {
.set(timeFrame.lendingStationId); .set(timeFrame.lendingStationId);
}); });
} catch (e) { } catch (e) {
console.log(e);
if (e instanceof UserInputError) { if (e instanceof UserInputError) {
return e; return e;
} else if (e instanceof QueryFailedError) { } else if (e instanceof QueryFailedError) {

@ -29,7 +29,6 @@ export class ProviderAPI extends DataSource {
async createProvider (provider: any) { async createProvider (provider: any) {
let inserts: any; let inserts: any;
try {
await this.connection.transaction(async (entityManager: any) => { await this.connection.transaction(async (entityManager: any) => {
inserts = await entityManager.getRepository(Provider) inserts = await entityManager.getRepository(Provider)
.createQueryBuilder('provider') .createQueryBuilder('provider')
@ -48,10 +47,7 @@ export class ProviderAPI extends DataSource {
.of(inserts.identifiers[0].id) .of(inserts.identifiers[0].id)
.add(provider.contactPersonIds); .add(provider.contactPersonIds);
}); });
} catch (e: any) {
console.log(e);
return new GraphQLError('Transaction could not be completed');
}
const ret = inserts.generatedMaps[0]; const ret = inserts.generatedMaps[0];
ret.id = inserts.identifiers[0].id; ret.id = inserts.identifiers[0].id;
return ret; return ret;

@ -40,7 +40,6 @@ export default {
ContactInformation: { ContactInformation: {
person: (parent: any, __: any, { dataSources, req }: { dataSources: any, req: any }) => { person: (parent: any, __: any, { dataSources, req }: { dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.ReadPerson)) { if (req.permissions.includes(Permission.ReadPerson)) {
console.log(parent);
return dataSources.contactInformationAPI.personByContactInformationId(parent.id); return dataSources.contactInformationAPI.personByContactInformationId(parent.id);
} else { } else {
return new GraphQLError('Insufficient Permissions'); return new GraphQLError('Insufficient Permissions');

Loading…
Cancel
Save