MCPcopy Create free account
hub / github.com/bsoc-bitbyte/busify / createSchedule

Method createSchedule

backend/src/Bus/bus.service.ts:96–138  ·  view source on GitHub ↗
(schedule: any)

Source from the content-addressed store, hash-verified

94 }
95
96 async createSchedule(schedule: any) {
97 const bus = await this.prismaService.bus.findFirst({
98 where: {number: schedule.busNumber},
99 });
100 schedule.bus = bus;
101 if (bus === null) {
102 schedule.bus = await this.createBus({
103 number: schedule.busNumber,
104 contractorId: (await this.getContractors())[0].id,
105 conductorId: (await this.getConductors())[0].id,
106 capacity: 50,
107 });
108 }
109
110 if (schedule.id !== null) {
111 await this.prismaService.schedule.update({
112 where: {id: schedule.id},
113 data: {
114 id: schedule.id,
115 busNumber: schedule.busNumber,
116 from: schedule.from,
117 to: schedule.to,
118 departureTime: schedule.departureTime,
119 checkpoints: schedule.checkpoints,
120 days: schedule.days,
121 },
122 });
123 return this.prismaService.schedule.findFirst({where: {id: schedule.id}});
124 }
125
126 return this.prismaService.schedule.create({
127 data: {
128 id: uuidv4(),
129 busNumber: schedule.busNumber as never,
130 from: schedule.from,
131 to: schedule.to,
132 departureTime: schedule.departureTime,
133 days: schedule.days,
134 checkpoints: schedule.checkpoints,
135 ticketPrice: 20,
136 },
137 });
138 }
139 async getBookedTickets() {}
140}

Callers 1

createNewScheduleMethod · 0.80

Calls 3

createBusMethod · 0.95
getContractorsMethod · 0.95
getConductorsMethod · 0.95

Tested by

no test coverage detected