Fix ws
This commit is contained in:
@@ -13,30 +13,30 @@ module.exports.getAllNotifs = async socket => {
|
||||
try {
|
||||
const allData = await Promise.all([
|
||||
// unreadCuMsgs
|
||||
ContactPageMessage.find({ read: false }),
|
||||
ContactPageMessage.countDocuments({ read: false }),
|
||||
|
||||
// unreadTickets
|
||||
TicketConversation.find({ messages: { $elemMatch: { isUser: true, read: false } } }),
|
||||
TicketConversation.countDocuments({ messages: { $elemMatch: { isUser: true, read: false } } }),
|
||||
|
||||
// newCustomers
|
||||
User.find({ scope: ['user'], seenByAdmin: false, confirmed: true }),
|
||||
User.countDocuments({ scope: ['user'], seenByAdmin: false, confirmed: true }),
|
||||
|
||||
// newRepresentations
|
||||
Representation.find({ status: 'registered' }),
|
||||
Representation.countDocuments({ status: 'registered' }),
|
||||
|
||||
// newPieceRequests
|
||||
PieceRequest.find({ status: 'sent' }),
|
||||
PieceRequest.countDocuments({ status: 'sent' }),
|
||||
|
||||
// newOldPieceRequests
|
||||
OldPieceRequest.find({ status: 'sent' }),
|
||||
OldPieceRequest.countDocuments({ status: 'sent' }),
|
||||
|
||||
// newBufferRequests
|
||||
BufferRequest.find({ status: 'sent' }),
|
||||
BufferRequest.countDocuments({ status: 'sent' }),
|
||||
|
||||
// newGuaranteeReports
|
||||
GuaranteeReport.find({ status: 'sent', seen: false }),
|
||||
GuaranteeReport.countDocuments({ status: 'sent', seen: false }),
|
||||
|
||||
Complaint.find({ read: false })
|
||||
Complaint.countDocuments({ read: false })
|
||||
])
|
||||
|
||||
const unreadCuMsgs = allData[0]
|
||||
@@ -47,19 +47,19 @@ module.exports.getAllNotifs = async socket => {
|
||||
const newOldPieceRequests = allData[5]
|
||||
const newBufferRequests = allData[6]
|
||||
const newGuaranteeReports = allData[7]
|
||||
const complaint = allData[8]
|
||||
const newComplaintReports = allData[8]
|
||||
|
||||
|
||||
socket.emit(`admin:allNotifs`, {
|
||||
unreadCuMsgs: unreadCuMsgs.length,
|
||||
unreadTickets: unreadTickets.length,
|
||||
newCustomers: newCustomers.length,
|
||||
newRepresentations: newRepresentations.length,
|
||||
newPieceRequests: newPieceRequests.length,
|
||||
newOldPieceRequests: newOldPieceRequests.length,
|
||||
newBufferRequests: newBufferRequests.length,
|
||||
newGuaranteeReports: newGuaranteeReports.length,
|
||||
newComplaintReports:complaint.length
|
||||
unreadCuMsgs,
|
||||
unreadTickets,
|
||||
newCustomers,
|
||||
newRepresentations,
|
||||
newPieceRequests,
|
||||
newOldPieceRequests,
|
||||
newBufferRequests,
|
||||
newGuaranteeReports,
|
||||
newComplaintReports
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/// / develop environment config
|
||||
const { isDev, isProduction, DevServerPort } = require('./_env')
|
||||
const wss = require('./WebSocket/wss')
|
||||
|
||||
/// / init express app (wrapping all functions into init() to prevent running in development mode by nuxt dev mode)
|
||||
function init() {
|
||||
// run preConfigured modules
|
||||
|
||||
Reference in New Issue
Block a user