Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added one more or condition in older for commissioning date filter an… #395

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ describe('CertificateLogService', () => {
end_date: '2024-02-14 12:51:000Z',
country: 'India',
SDGBenefits: undefined,
oldcertificatelog: false,
};
const pageNumber = 1;

Expand Down Expand Up @@ -559,6 +560,7 @@ describe('CertificateLogService', () => {
end_date: '2024-02-14 12:51:000Z',
country: 'India',
SDGBenefits: undefined,
oldcertificatelog: false,
};
const pageNumber = 1;

Expand Down
34 changes: 27 additions & 7 deletions apps/drec-api/src/pods/certificate-log/certificate-log.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ export class CertificateLogService {
currentpage?: number;
totalPages: number;
totalCount: number;
oldcertificatelog: boolean;
}> {
this.logger.verbose(`With in getCertifiedlogofDevices`);
const getnewreservationinfo =
Expand All @@ -656,27 +657,46 @@ export class CertificateLogService {
'getoldreservationinfo',
getoldreservationinfo.deviceGroups.length,
);
if (getnewreservationinfo.deviceGroups.length > 0) {
const oldcertificatelog = this.isTrue(filterDto.oldcertificatelog);
if (!oldcertificatelog && getnewreservationinfo.deviceGroups.length > 0) {
this.logger.debug('Line No: 580');
return this.getDeveloperCertificatesUsingGroupIDVersionUpdateOrigin247(
getnewreservationinfo,
user.role,
);
const newlog =
await this.getDeveloperCertificatesUsingGroupIDVersionUpdateOrigin247(
getnewreservationinfo,
user.role,
);

return {
...newlog,
oldcertificatelog:
getoldreservationinfo.deviceGroups.length > 0 ? true : false,
};
}
if (getoldreservationinfo.deviceGroups.length > 0) {
return this.getDeveloperfindreservationcertified(

if (oldcertificatelog && getoldreservationinfo.deviceGroups.length > 0) {
this.logger.debug('Line No: 581');
const oldlog = await this.getDeveloperfindreservationcertified(
getoldreservationinfo,
user.role,
);
return {
...oldlog,
oldcertificatelog:
getoldreservationinfo.deviceGroups.length > 0 ? true : false,
};
}

return {
certificatelog: [],
currentpage: 0,
totalPages: 0,
totalCount: 0,
oldcertificatelog: false,
};
}
isTrue(value: string | boolean): boolean {
return value === 'true' || value === true;
}

async getDeveloperfindreservationcertified(
certifiedreservation:
Expand Down
7 changes: 7 additions & 0 deletions apps/drec-api/src/pods/certificate-log/dto/filter.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class FilterDTO {
@IsOptional()
@ApiPropertyOptional({ description: 'Certificate End date filter' })
end_date: string;

@IsOptional()
@ApiPropertyOptional({ type: String, description: 'Country' })
country: string;
Expand All @@ -65,6 +66,12 @@ export class FilterDTO {
isArray: true,
})
SDGBenefits?: string[] | undefined;
@IsOptional()
@ApiPropertyOptional({
type: Boolean,
description: 'old certificate',
})
oldcertificatelog?: boolean;
}

export class GroupIDBasedFilteringDTO {
Expand Down
13 changes: 10 additions & 3 deletions apps/drec-api/src/pods/device-group/device-group.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2586,10 +2586,10 @@ export class DeviceGroupService {
},
);
qb.orWhere(
'crm.generationEndTime BETWEEN :certificateStartDate1 AND :certificateEndDate1',
'crm.generationEndTime BETWEEN :certificateStartDate2 AND :certificateEndDate2',
{
certificateStartDate1: startTimestamp,
certificateEndDate1: endTimestamp,
certificateStartDate2: startTimestamp,
certificateEndDate2: endTimestamp,
},
);
}
Expand Down Expand Up @@ -2860,6 +2860,13 @@ export class DeviceGroupService {
certificateEndDate1: endTimestamp,
},
);
qb.orWhere(
'issuer.generationEndTime BETWEEN :certificateStartDate2 AND :certificateEndDate2',
{
certificateStartDate2: startTimestamp,
certificateEndDate2: endTimestamp,
},
);
}
if (filterDto.SDGBenefits) {
const newsdg = filterDto.SDGBenefits.toString();
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.144
0.0.145
Loading