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.logger = config.getLogger('splash-controller.ts');
|
||||||
this.userSplashService = userSplashService;
|
this.userSplashService = userSplashService;
|
||||||
|
|
||||||
this.post('/', this.recordSplash);
|
this.post('/:id', this.updateSplashSettings);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async updateSplashSettings(
|
private async updateSplashSettings(
|
||||||
@ -66,9 +39,8 @@ class UserSplashController extends Controller {
|
|||||||
...req.body,
|
...req.body,
|
||||||
splashId: id,
|
splashId: id,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
seen: req.body.seen || false,
|
seen: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const updated = await this.userSplashService.updateSplash(splash);
|
const updated = await this.userSplashService.updateSplash(splash);
|
||||||
res.json(updated);
|
res.json(updated);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ export default class UserSplashService {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const splashs = await (
|
const splashs = (
|
||||||
await this.userSplashStore.getAllUserSplashs(user.id)
|
await this.userSplashStore.getAllUserSplashs(user.id)
|
||||||
).reduce(
|
).reduce(
|
||||||
(splashObject, splash) => ({
|
(splashObject, splash) => ({
|
||||||
|
@ -2,8 +2,7 @@ exports.up = function (db, cb) {
|
|||||||
db.runSql(`SELECT * FROM users`, (err, results) => {
|
db.runSql(`SELECT * FROM users`, (err, results) => {
|
||||||
results.rows.forEach((user) => {
|
results.rows.forEach((user) => {
|
||||||
db.runSql(
|
db.runSql(
|
||||||
`INSERT INTO user_splash(splash_id, user_id, seen) VALUES (?, ?, ?)`,
|
`INSERT INTO user_splash(splash_id, user_id, seen) SELECT 'environment', u.id, false FROM users u`,
|
||||||
['environments', user.id, false],
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
cb();
|
cb();
|
||||||
|
Loading…
Reference in New Issue
Block a user