Skip to content

Commit

Permalink
Merge pull request #211 from d-rec/DR-785
Browse files Browse the repository at this point in the history
DR-785,worked on certificate issue,change in issuermeta data payload …
  • Loading branch information
NamrataSweya authored May 10, 2024
2 parents b77eb39 + 9875c42 commit 0b556e6
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 237 deletions.
20 changes: 17 additions & 3 deletions apps/drec-api/src/pods/certificate-log/certificate-log.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,15 @@ export class CertificateLogService {
); //going back 1 second in start and going forward 1 second in end

await Promise.all(
obj.deviceIds.map(async (deviceid: number) => {
const device = await this.deviceService.findOne(deviceid);
obj.deviceIds.map(async (deviceid) => {
let device: Device;
if (typeof deviceid === 'number') {
device = await this.deviceService.findOne(deviceid);
}
if (typeof deviceid === 'string') {
device = await this.deviceService.findReads(deviceid);
}

const devicelog =
await this.getCheckCertificateIssueDateLogForDevice(
parseInt(groupid),
Expand Down Expand Up @@ -291,7 +298,14 @@ export class CertificateLogService {

await Promise.all(
obj.deviceIds.map(async (deviceid: number) => {
const device = await this.deviceService.findOne(deviceid);
let device: Device;
if (typeof deviceid === 'number') {
device = await this.deviceService.findOne(deviceid);
}
if (typeof deviceid === 'string') {
device = await this.deviceService.findReads(deviceid);
}

const devicelog =
await this.getCheckCertificateIssueDateLogForDevice(
parseInt(groupid),
Expand Down
6 changes: 5 additions & 1 deletion apps/drec-api/src/pods/device/device.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,15 @@ export class DeviceService {
return device;
}

async findReads(meterId: string): Promise<DeviceDTO | null> {
async findReads(meterId: string): Promise<Device | null> {
this.logger.verbose(`With in findReads`);
const result = await this.repository.findOne({
where: { externalId: meterId },
});
result.timezone = await getLocalTimeZoneFromDevice(
result.createdAt,
result,
);
delete result['organization'];

return result ?? null;
Expand Down
Loading

0 comments on commit 0b556e6

Please sign in to comment.