Added optimization to reduce unnecessary requests

This commit is contained in:
irtiza-h30
2021-08-23 14:23:14 -04:00
parent 0330eb7f39
commit dc049dedf7

View File

@@ -264,18 +264,26 @@ export class API extends RESTDataSource {
if (profile.profileType === 'ssid') {
const {
id,
details: { passpointProfileId, passpointConfig },
details: { passpointProfileId = {}, passpointConfig },
} = profile;
const oldProfile = await this.get('portal/profile', { profileId: id });
if (oldProfile.childProfileIds.length) {
const childProfiles = await this.get('portal/profile/inSet', {
const childProfiles =
(await this.get('portal/profile/inSet', {
profileIdSet: oldProfile.childProfileIds,
});
})) || [];
const passpointProfile = childProfiles.find(
(profile) => profile.profileType === 'passpoint'
);
console.log(passpointProfileId.value);
if (passpointProfile) {
if (
!passpointProfileId.value ||
passpointProfile.id !== parseInt(passpointProfileId.value, 10)
) {
this.put('portal/profile', {
...passpointProfile,
details: {
@@ -292,7 +300,9 @@ export class API extends RESTDataSource {
});
}
}
}
if (passpointProfileId.value) {
if (passpointConfig === 'accessSSID') {
this.get('portal/profile', {
profileId: passpointProfileId.value,
@@ -340,6 +350,7 @@ export class API extends RESTDataSource {
});
}
}
}
return this.put('portal/profile', {
...profile,
@@ -352,9 +363,11 @@ export class API extends RESTDataSource {
if (deletedProfile.profileType === 'ssid') {
if (deletedProfile.childProfileIds.length) {
const childProfiles = await this.get('portal/profile/inSet', {
const childProfiles =
(await this.get('portal/profile/inSet', {
profileIdSet: deletedProfile.childProfileIds,
});
})) || [];
const passpointProfile = childProfiles.find(
(profile) => profile.profileType === 'passpoint'
);