Skip to content

Commit 3d1b751

Browse files
committed
Cleaning up info sources
1 parent c811da6 commit 3d1b751

File tree

2 files changed

+17
-22
lines changed

2 files changed

+17
-22
lines changed

src/api/routes/aircrash-router.ts

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -121,35 +121,37 @@ aircrashRouter.put(
121121
await db('AirCrash.AirCrash')
122122
.update(aircrash)
123123
.where('AirCrash.AirCrash.yacsinumber', aircrashId);
124-
const doSources = false;
125-
if (doSources) {
124+
126125
//Add the new info sources (in progress)
127-
await db
128-
.insert(
129-
newInfoSources.map((source: any) => ({
130-
YACSINumber: aircrashId,
131-
...source,
132-
}))
133-
)
134-
.into('AirCrash.InfoSource')
135-
.then((rows: any) => {
136-
return rows;
137-
});
126+
127+
if (newInfoSources && newInfoSources.length > 0) {
128+
129+
await db
130+
.insert(
131+
newInfoSources.map((source: any) => ({
132+
YACSINumber: aircrashId,
133+
...source,
134+
}))
135+
)
136+
.into('AirCrash.InfoSource');
137+
}
138138

139139
//remove the previous owners (DONE)
140140
for (const obj of removedInfoSources) {
141+
141142
await db('AirCrash.InfoSource')
142143
.where('AirCrash.InfoSource.Id', obj.Id)
143144
.del();
144145
}
145146

146147
//update the info sources (DONE)
147148
for (const obj of editedInfoSources) {
149+
148150
await db('AirCrash.InfoSource')
149151
.update({ Source: obj.Source })
150152
.where('AirCrash.InfoSource.Id', obj.Id);
151153
}
152-
}
154+
153155
res.status(200).send({ message: 'success' });
154156
}
155157
);
@@ -187,13 +189,7 @@ aircrashRouter.post('/', async (req: Request, res: Response) => {
187189
...source,
188190
}));
189191

190-
await db
191-
.insert(finalInfoSources)
192-
.into('AirCrash.InfoSource')
193-
.returning('*')
194-
.then((rows: any) => {
195-
return rows;
196-
});
192+
await db.insert(finalInfoSources).into('AirCrash.InfoSource');
197193
}
198194

199195
return newAirCrash;

src/web/src/modules/AirplaneCrashes/components/InfoSources.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@
122122
>
123123
</v-col>
124124
</v-row>
125-
{{ indexOfSourceBeingEdited }}
126125
</div>
127126
</template>
128127

0 commit comments

Comments
 (0)