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:
parent
cd38c5a01d
commit
c4e56aae09
@ -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);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ export default class UserSplashService {
|
||||
return [];
|
||||
}
|
||||
try {
|
||||
const splashs = await (
|
||||
const splashs = (
|
||||
await this.userSplashStore.getAllUserSplashs(user.id)
|
||||
).reduce(
|
||||
(splashObject, splash) => ({
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user