1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-14 00:19:16 +01:00

fix: remove record splash and update sql query in add-splash-entry

This commit is contained in:
Youssef 2021-11-12 10:49:09 +01:00
parent cd38c5a01d
commit c4e56aae09
3 changed files with 4 additions and 33 deletions

View File

@ -25,34 +25,7 @@ class UserSplashController extends Controller {
this.logger = config.getLogger('splash-controller.ts');
this.userSplashService = userSplashService;
this.post('/', this.recordSplash);
this.put('/:id', this.updateSplashSettings);
}
private async recordSplash(
req: IAuthRequest<any, any, ISplashBody, any>,
res: Response,
): Promise<void> {
const BAD_REQUEST = 400;
const { user } = req;
const { splashId } = req.body;
if (!splashId) {
res.status(BAD_REQUEST).json({
error: 'splashId must be present.',
});
return;
}
const splash = {
...req.body,
userId: user.id,
seen: req.body.seen || false,
};
const updated = await this.userSplashService.updateSplash(splash);
res.json(updated);
this.post('/:id', this.updateSplashSettings);
}
private async updateSplashSettings(
@ -66,9 +39,8 @@ class UserSplashController extends Controller {
...req.body,
splashId: id,
userId: user.id,
seen: req.body.seen || false,
seen: true,
};
const updated = await this.userSplashService.updateSplash(splash);
res.json(updated);
}

View File

@ -25,7 +25,7 @@ export default class UserSplashService {
return [];
}
try {
const splashs = await (
const splashs = (
await this.userSplashStore.getAllUserSplashs(user.id)
).reduce(
(splashObject, splash) => ({

View File

@ -2,8 +2,7 @@ exports.up = function (db, cb) {
db.runSql(`SELECT * FROM users`, (err, results) => {
results.rows.forEach((user) => {
db.runSql(
`INSERT INTO user_splash(splash_id, user_id, seen) VALUES (?, ?, ?)`,
['environments', user.id, false],
`INSERT INTO user_splash(splash_id, user_id, seen) SELECT 'environment', u.id, false FROM users u`,
);
});
cb();