Compare commits
2 Commits
cec927ba0b
...
652c389840
Author | SHA1 | Date |
---|---|---|
|
652c389840 | |
|
b9afde051e |
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "traxxx-web",
|
"name": "traxxx-web",
|
||||||
"version": "0.19.0",
|
"version": "0.19.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"version": "0.19.0",
|
"version": "0.19.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@brillout/json-serializer": "^0.5.8",
|
"@brillout/json-serializer": "^0.5.8",
|
||||||
"@dicebear/collection": "^7.0.5",
|
"@dicebear/collection": "^7.0.5",
|
||||||
|
|
|
@ -75,5 +75,5 @@
|
||||||
"postcss-custom-media": "^10.0.2",
|
"postcss-custom-media": "^10.0.2",
|
||||||
"postcss-nesting": "^12.0.2"
|
"postcss-nesting": "^12.0.2"
|
||||||
},
|
},
|
||||||
"version": "0.19.0"
|
"version": "0.19.1"
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,8 @@ export async function fetchNotifications(reqUser, options = {}) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const notifications = await knex('notifications')
|
const [notifications, rawUnseen] = await Promise.all([
|
||||||
|
knex('notifications')
|
||||||
.select(
|
.select(
|
||||||
'notifications.*',
|
'notifications.*',
|
||||||
'alerts.id as alert_id',
|
'alerts.id as alert_id',
|
||||||
|
@ -165,15 +166,20 @@ export async function fetchNotifications(reqUser, options = {}) {
|
||||||
.leftJoin('alerts_entities', 'alerts_entities.alert_id', 'alerts.id')
|
.leftJoin('alerts_entities', 'alerts_entities.alert_id', 'alerts.id')
|
||||||
.leftJoin('alerts_matches', 'alerts_matches.alert_id', 'alerts.id')
|
.leftJoin('alerts_matches', 'alerts_matches.alert_id', 'alerts.id')
|
||||||
.where('notifications.user_id', reqUser.id)
|
.where('notifications.user_id', reqUser.id)
|
||||||
|
.limit(options.limit)
|
||||||
.groupBy('notifications.id', 'alerts.id')
|
.groupBy('notifications.id', 'alerts.id')
|
||||||
.orderBy('created_at', 'desc');
|
.orderBy('created_at', 'desc'),
|
||||||
|
knex('notifications')
|
||||||
|
.select(knex.raw('count(id)'))
|
||||||
|
.where('user_id', reqUser.id)
|
||||||
|
.where('seen', false)
|
||||||
|
.first(),
|
||||||
|
]);
|
||||||
|
|
||||||
const scenes = await fetchScenesById(notifications.map((notification) => notification.scene_id));
|
const scenes = await fetchScenesById(notifications.map((notification) => notification.scene_id));
|
||||||
const unseen = notifications.filter((notification) => !notification.seen).length;
|
const unseen = Number(rawUnseen.count);
|
||||||
|
|
||||||
const curatedNotifications = notifications
|
const curatedNotifications = notifications.map((notification) => {
|
||||||
.slice(0, options.limit || 10)
|
|
||||||
.map((notification) => {
|
|
||||||
const scene = scenes.find((sceneX) => sceneX.id === notification.scene_id);
|
const scene = scenes.find((sceneX) => sceneX.id === notification.scene_id);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue