add filter

This commit is contained in:
Peter Maquiran
2024-06-17 10:33:35 +01:00
parent 54cdf512c0
commit 768dc10308
10 changed files with 135 additions and 55 deletions
@@ -83,13 +83,14 @@ export class AgendaDataRepositoryService {
if(isHttpError(e)) {
tracing?.setAttribute('status.code', e.status.toString())
} else {
console.error(e)
tracing?.setAttribute('map.error', JSON.stringify(e.error))
}
return err(e as HttpErrorResponse)
}
}
async eventToApproveList({ userId, startDate = null, endDate = null, status = EEventFilterStatus.Pending, category = null, type = null, calendarOwnerName = '' }) {
async eventToApproveList({ userId, startDate = null, endDate = null, status = EEventFilterStatus.Pending, category = null, type = null, calendarOwnerName = '' }, tracing?: TracingType) {
try {
const result = await this.agendaDataService.getEvents(userId, startDate = null, endDate = null, status, category = null, type = null).pipe(
@@ -100,6 +101,12 @@ export class AgendaDataRepositoryService {
return ok(result)
} catch (e) {
if(isHttpError(e)) {
tracing?.setAttribute('status.code', e.status.toString())
} else {
console.error(e)
tracing?.setAttribute('map.error', JSON.stringify(e.error))
}
return err(e as HttpErrorResponse)
}
}
@@ -54,10 +54,10 @@ export class AgendaDataService {
}
if(status == -1 || status == undefined) {
if(status != null || status != undefined) {
params = params.set('status', status);
}
if (startDate !== null && startDate !== undefined) {
params = params.set('startDate', startDate);
}
+1 -1
View File
@@ -75,7 +75,7 @@ export class ListBoxService {
// daysObject[day] = object[day]
// }
console.log('newStracture', newStracture)
// console.log('newStracture', newStracture)
return this.display(newStracture, selectedDate).year
@@ -15,7 +15,7 @@ Device.getInfo().then(e => {
device = e
});
export function XTracerAsync({name, log, bugPrint}: any) {
export function XTracerAsync({ name, log, bugPrint }: any, p0?: any) {
return (
target: unknown,
propertyKey: string,
@@ -26,12 +26,14 @@ export function XTracerAsync({name, log, bugPrint}: any) {
const requestId = uuidv4()
const span = tracerInstance.startSpan(name);
let hasBug:Boolean
const createTracingInstance = (): TracingType => {
const logs: any[] = []
const data = {
event: {},
tags: {}
}
const createTracingInstance = (): TracingType => {
return {
span: span as any,
@@ -42,27 +44,23 @@ export function XTracerAsync({name, log, bugPrint}: any) {
span.setStatus(status);
},
addEvent: (context: string, message?: any, obj?: any) => {
if(log == true) {
// logger.error(obj, context, message)
} else {
logs.push({context, message: message, obj})
}
data.event[context] = message;
const value = [JSON.stringify(message)] as any
span.addEvent(context, value);
},
LocalLogEvent:(context: string, message: any, obj: any) => {
logs.push({context, message, obj})
data.tags[context] = message;
},
setAttribute: (key: string, value: string) => {
data.tags[key] = value;
span.setAttribute(key, value);
},
finish: () => {
span.end();
if(bugPrint && hasBug) {
for(const {context, message, obj} of logs) {
// logger.error(obj, context, message)
}
console.error(name, data)
}
},
bugFlag:() => {
@@ -76,7 +74,7 @@ export function XTracerAsync({name, log, bugPrint}: any) {
const tracing = createTracingInstance()
tracing.setAttribute('current.page', window.location.pathname);
tracing.setAttribute('device.name', device.name || device.model)
tracing.setAttribute('device.name', device?.name || device?.model)
args.push(tracing)
@@ -111,9 +109,12 @@ export function XTracer({name, log, bugPrint}: any) {
let hasBug:Boolean
const createTracingInstance = (): TracingType => {
const logs: any[] = []
const data = {
event: {},
tags: {}
}
const createTracingInstance = (): TracingType => {
return {
span: span as any,
@@ -124,27 +125,23 @@ export function XTracer({name, log, bugPrint}: any) {
span.setStatus(status);
},
addEvent: (context: string, message?: any, obj?: any) => {
if(log == true) {
// logger.error(obj, context, message)
} else {
logs.push({context, message: message, obj})
}
data.event[context] = message;
const value = [JSON.stringify(message)] as any
span.addEvent(context, value);
},
LocalLogEvent:(context: string, message: any, obj: any) => {
logs.push({context, message, obj})
data.tags[context] = message;
},
setAttribute: (key: string, value: any) => {
setAttribute: (key: string, value: string) => {
data.tags[key] = value;
span.setAttribute(key, value);
},
finish: () => {
span.end();
if(bugPrint && hasBug) {
for(const {context, message, obj} of logs) {
// logger.error(obj, context, message)
}
console.error(name, data)
}
},
bugFlag:() => {
@@ -158,7 +155,7 @@ export function XTracer({name, log, bugPrint}: any) {
const tracing = createTracingInstance()
tracing.setAttribute('current.page', window.location.pathname);
tracing.setAttribute('device.name', device.name || device.model)
tracing.setAttribute('device.name', device?.name || device?.model)
args.push(tracing)
+13 -2
View File
@@ -21,6 +21,8 @@ import { ChangeProfileService } from './change-profile.service';
import { PermissionService } from './permission.service';
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
import { SortService } from './functions/sort.service';
import { TracingType, XTracerAsync } from './monitoring/opentelemetry/tracer';
import { EEventFilterStatus } from './Repositorys/Agenda/model/enums';
@Injectable({
providedIn: 'root'
})
@@ -311,7 +313,8 @@ export class TaskService {
}
async loadEventosParaAprovacao() {
@XTracerAsync({name:'taskService/loadEventosParaAprovacao', log: false, bugPrint: true})
async loadEventosParaAprovacao(tracing?: TracingType) {
this.showLoaderNum++
console.log('PR')
// PR dont have event to approve
@@ -328,8 +331,13 @@ export class TaskService {
userId = calendar.OwnerUserId
}
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({userId})
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({
userId,
status: EEventFilterStatus.Pending
})
if(allEvents.isOk()) {
tracing.setAttribute('outcome', 'success')
let eventsList = []
if(allEvents.value.length >= 1) {
@@ -338,6 +346,9 @@ export class TaskService {
} else {
this.eventoaprovacaostore.save(userId, [])
}
} else {
tracing.setAttribute('outcome', 'failed')
}
}
} catch (error) {