mirror of
https://github.com/Telecominfraproject/wlan-cloud-graphql-gw.git
synced 2025-10-30 10:12:39 +00:00
Added optimization to reduce unnecessary requests
This commit is contained in:
@@ -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'
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user