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

@ -49,12 +49,7 @@ export const reportUserService= async (req: Request, res: Response): Promise<Res
throw new AppError("ERR_NO_PERMISSION", 403);
}
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'})
@ -64,13 +59,7 @@ 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 })))
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) => {
@ -109,13 +98,7 @@ export const reportUserService= async (req: Request, res: Response): Promise<Res
user.endDate = `${date[2]}/${date[1]}/${date[0]}`
}
})
console.log('')
console.log('usersProfile2: ',usersProfile)
//
// const data_query = await ShowTicketReport(userId, startDate, endDate);
})
return res.status(200).json(usersProfile);

View File

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

View File

@ -30,19 +30,7 @@ let timeInterval = 5
let lstOnline: any = []
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) => {
@ -73,137 +61,126 @@ const emitterOnline = (user: any, status: string, showOnlineTime: boolean = true
const monitor = async () => {
const test = require('./../libs/socket');
try {
if (test.ob) {
if (count > 1) {
count = 0
}
if (count == 0) {
uuid = test.ob.uuid
}
if (count == 1) {
if (uuid) {
if (uuid == test.ob.uuid) {
console.log('ALL USERS CLIENTS OFFLINE 1...........')
//await setOfflineAllUsers()
test.ob.listOnline = []
test.ob.listOnlineAux = []
test.ob.uuid = undefined
}
const usersSocket = require('./../libs/socket');
if (usersSocket.ob) {
if (count > 1) {
count = 0
}
} else {
// 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 (count == 0) {
uuid = usersSocket.ob.uuid
}
if (count == 1) {
if (uuid) {
if (uuid == usersSocket.ob.uuid) {
console.log('ALL USERS CLIENTS OFFLINE 1...........')
usersSocket.ob.listOnline = []
usersSocket.ob.listOnlineAux = []
usersSocket.ob.uuid = undefined
}
}
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)
} 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' })
}
})
}
count++
}
count++
}
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 > 5) {
countTest = 0
}
}
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)
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()
}
};

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 })))
//
export const initIO = (httpServer: Server): SocketIO => {
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));
//console.log('>>>>>>>>>>> difference: ', difference)
if (difference.length > 0) {
@ -156,15 +150,11 @@ export const initIO = (httpServer: Server): SocketIO => {
})
// console.log(' difference2: ', difference)
}
obj.listOnline = lstOnline
obj.listOnlineAux = lstOnlineAux
// console.log(' >>>>>> lstOnline: ', lstOnline)
// console.log('')
// console.log(' >>>>>> lstOnlineAux: ', lstOnlineAux)
lstOnlineAux = []
listOnlineAux = []