Limpeza de comentários na master

pull/1/head
adriano 2022-05-16 01:03:16 -03:00
parent c7fa85c509
commit c6d6ec2103
4 changed files with 121 additions and 166 deletions

View File

@ -51,11 +51,6 @@ export const reportUserService= async (req: Request, res: Response): Promise<Res
const { userId, startDate, endDate } = req.query as IndexQuery const { userId, startDate, endDate } = req.query as IndexQuery
//test del
console.log('startDate: ', startDate)
console.log('endDate: ', endDate)
console.log('userId: ', userId)
let usersProfile = await ListUserParamiterService({profile: 'user'}) let usersProfile = await ListUserParamiterService({profile: 'user'})
const sumUserOlineTime = await ShowUserServiceReport({startDate, endDate, userId}); const sumUserOlineTime = await ShowUserServiceReport({startDate, endDate, userId});
@ -65,12 +60,6 @@ export const reportUserService= async (req: Request, res: Response): Promise<Res
let dateTime = splitDateTime(new Date(format(new Date(), 'yyyy-MM-dd HH:mm:ss', { locale: ptBR }))) let dateTime = splitDateTime(new Date(format(new Date(), 'yyyy-MM-dd HH:mm:ss', { locale: ptBR })))
const onlineUsers = await ListUserOnlineOffline({ date: dateTime.fullDate }) const onlineUsers = await ListUserOnlineOffline({ date: dateTime.fullDate })
console.log('sumUserOlineTime: ',sumUserOlineTime )
console.log('closedByUser: ',closedByUser )
console.log('openByUser: ',openByUser )
console.log('usersProfile: ', usersProfile)
console.log('')
usersProfile.map((user:any) => { usersProfile.map((user:any) => {
@ -110,12 +99,6 @@ export const reportUserService= async (req: Request, res: Response): Promise<Res
} }
}) })
console.log('')
console.log('usersProfile2: ',usersProfile)
//
// const data_query = await ShowTicketReport(userId, startDate, endDate);
return res.status(200).json(usersProfile); return res.status(200).json(usersProfile);

View File

@ -8,6 +8,7 @@ import DeleteSchedulingNotifyService from "../services/SchedulingNotifyServices
let scheduler_monitor:any; let scheduler_monitor:any;
let timeInterval = 5
const monitor = async () => { const monitor = async () => {
@ -45,6 +46,8 @@ const monitor = async () => {
} catch (error) { } catch (error) {
console.log('>>> SchedulingNotifiySendMessage.ts error: ', error) console.log('>>> SchedulingNotifiySendMessage.ts error: ', error)
stopSchedulingMonitor()
startSchedulingMonitor(timeInterval)
} }
}; };
@ -52,6 +55,8 @@ const monitor = async () => {
export const startSchedulingMonitor =async (mileseconds: number) => { export const startSchedulingMonitor =async (mileseconds: number) => {
timeInterval = mileseconds
scheduler_monitor = setInterval(monitor, mileseconds) scheduler_monitor = setInterval(monitor, mileseconds)
} }

View File

@ -31,18 +31,6 @@ let lstOnline: any = []
let deleted: boolean = false; let deleted: boolean = false;
const setOfflineAllUsers = async () => {
// const onlineUsers = await ListUserOnlineOffline({ date: dateTime.fullDate, status: 'online' })
// console.log('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX onlineUsers: ', onlineUsers)
// if (onlineUsers.length > 0) {
// onlineUsers.forEach(async user => {
// await createOrUpdateOnlineUserService({ userId: user.userId, status: 'offline' })
// });
// }
}
const emitterOnline = (user: any, status: string, showOnlineTime: boolean = true) => { const emitterOnline = (user: any, status: string, showOnlineTime: boolean = true) => {
@ -73,137 +61,126 @@ const emitterOnline = (user: any, status: string, showOnlineTime: boolean = true
const monitor = async () => { const monitor = async () => {
const test = require('./../libs/socket'); try {
if (test.ob) { const usersSocket = require('./../libs/socket');
if (count > 1) { if (usersSocket.ob) {
count = 0
}
if (count == 0) { if (count > 1) {
uuid = test.ob.uuid count = 0
} }
if (count == 1) { if (count == 0) {
if (uuid) { uuid = usersSocket.ob.uuid
if (uuid == test.ob.uuid) { }
console.log('ALL USERS CLIENTS OFFLINE 1...........') if (count == 1) {
if (uuid) {
if (uuid == usersSocket.ob.uuid) {
//await setOfflineAllUsers() console.log('ALL USERS CLIENTS OFFLINE 1...........')
test.ob.listOnline = []
test.ob.listOnlineAux = [] usersSocket.ob.listOnline = []
test.ob.uuid = undefined usersSocket.ob.listOnlineAux = []
usersSocket.ob.uuid = undefined
}
} }
} else {
usersSocket.ob.listOnline.forEach(async (el: any) => {
const indexAux = lstOnline.findIndex((e: any) => e.id == el.id)
if (indexAux == -1) {
console.log(' entrou indexAux: ', indexAux)
const userOnline = await createOrUpdateOnlineUserService({ userId: el.id, status: 'online' })
if (userOnline) {
el.onlineTime = userOnline.onlineTime
el.updatedAt = userOnline.updatedAt,
console.log(' * CREATED OR UPDATED USER TO ONLINE: ', userOnline.userId)
lstOnline.push({ 'id': el.id, 'status': 'online' })
}
}
if (el.status == 'waiting...') {
emitterOnline(el, el.status, false)
}
else {
emitterOnline(el, el.status)
}
});
let difference = lstOnline.filter((x: any) => !usersSocket.ob.listOnline.map((e: any) => e.id).includes(x.id));
difference.forEach(async (e: any) => {
const index = lstOnline.findIndex((x: any) => x.id == e.id)
if (index != -1) {
lstOnline.splice(index, 1)
const userOnline = await createOrUpdateOnlineUserService({ userId: e.id, status: 'offline' })
}
})
} }
} else { count++
// console.log(' * TEST OBJ', test.ob)
test.ob.listOnline.forEach(async (el: any) => {
const indexAux = lstOnline.findIndex((e: any) => e.id == el.id)
if (indexAux == -1) {
console.log(' entrou indexAux: ', indexAux)
const userOnline = await createOrUpdateOnlineUserService({ userId: el.id, status: 'online' })
if (userOnline) {
el.onlineTime = userOnline.onlineTime
el.updatedAt = userOnline.updatedAt,
console.log(' * CREATED OR UPDATED USER TO ONLINE: ', userOnline.userId)
lstOnline.push({ 'id': el.id, 'status': 'online' })
}
}
if (el.status == 'waiting...') {
emitterOnline(el, el.status, false)
}
else {
emitterOnline(el, el.status)
}
});
// console.log('----------- 1 lstOnline: ', lstOnline)
let difference = lstOnline.filter((x: any) => !test.ob.listOnline.map((e: any) => e.id).includes(x.id));
// console.log(' * diference: ', difference)
difference.forEach(async (e: any) => {
const index = lstOnline.findIndex((x: any) => x.id == e.id)
if (index != -1) {
lstOnline.splice(index, 1)
// console.log('----------- 2 lstOnline: ', lstOnline)
const userOnline = await createOrUpdateOnlineUserService({ userId: e.id, status: 'offline' })
if (userOnline) {
// console.log(' * UPDATED USER TO OFFLINE: ', userOnline.userId)
}
}
})
} }
count++ if (countTest > 5) {
countTest = 0
}
if (countTest > 5) {
countTest = 0
}
if (countTest == 0) {
try {
console.log(' Carregando usuárion no listUserId...')
listUserId = await ListUserParamiterService({ profile: 'user' })
} catch (error) {
console.log('There was an erro on ListUserParamiterService: ', error)
return
} }
if (countTest == 0) {
try {
// console.log(' Carregando usuárion no listUserId...')
listUserId = await ListUserParamiterService({ profile: 'user' })
} catch (error) {
console.log('There was an erro on ListUserParamiterService: ', error)
return
}
}
countTest = 1
listUserId.forEach((u) => {
const io = getIO();
io.emit("isOnline", { action: "online", userId: u.id });
});
} catch (error) {
console.log('>>> There was an error no WhoIsOnlineMonitor.ts: ',error)
stopWhoIsOnlineMonitor()
startWhoIsOnlineMonitor()
} }
countTest = 1
listUserId.forEach((u) => {
// console.log(' *** listUserId: ', listUserId)
const io = getIO();
io.emit("isOnline", { action: "online", userId: u.id });
});
// console.log('***************** TIME INTERVAL: ', timeInterval)
}; };

View File

@ -33,11 +33,6 @@ let lstTry: any[] = []
let dateTime = splitDateTime(new Date(format(new Date(), 'yyyy-MM-dd HH:mm:ss', { locale: ptBR }))) let dateTime = splitDateTime(new Date(format(new Date(), 'yyyy-MM-dd HH:mm:ss', { locale: ptBR })))
//
export const initIO = (httpServer: Server): SocketIO => { export const initIO = (httpServer: Server): SocketIO => {
io = new SocketIO(httpServer, { io = new SocketIO(httpServer, {
@ -131,7 +126,6 @@ export const initIO = (httpServer: Server): SocketIO => {
var difference = lstOnline.filter((x: any) => !lstOnlineAux.map((e: any) => e.id).includes(x.id)); var difference = lstOnline.filter((x: any) => !lstOnlineAux.map((e: any) => e.id).includes(x.id));
//console.log('>>>>>>>>>>> difference: ', difference)
if (difference.length > 0) { if (difference.length > 0) {
@ -156,15 +150,11 @@ export const initIO = (httpServer: Server): SocketIO => {
}) })
// console.log(' difference2: ', difference)
} }
obj.listOnline = lstOnline obj.listOnline = lstOnline
obj.listOnlineAux = lstOnlineAux obj.listOnlineAux = lstOnlineAux
// console.log(' >>>>>> lstOnline: ', lstOnline)
// console.log('')
// console.log(' >>>>>> lstOnlineAux: ', lstOnlineAux)
lstOnlineAux = [] lstOnlineAux = []
listOnlineAux = [] listOnlineAux = []