rez_core 2.1.72 → 2.1.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "2.1.72",
3
+ "version": "2.1.74",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -61,56 +61,77 @@ export class SchoolRepository {
61
61
  .where('org.id = :orgId', { orgId: currentORGLevel_id })
62
62
  .getRawMany();
63
63
 
64
- const result = {};
65
- for (const row of schools) {
66
- const {
67
- org_id,
68
- org_name,
69
- org_address,
70
- org_status,
71
- brand_id,
72
- brand_name,
73
- brand_status,
74
- school_id,
75
- school_name,
76
- school_location,
77
- school_status,
78
- } = row;
79
-
80
- if (!result[org_id]) {
81
- result[org_id] = {
64
+ if (schools.length > 0) {
65
+ const result = {};
66
+ for (const row of schools) {
67
+ const {
82
68
  org_id,
83
69
  org_name,
84
70
  org_address,
85
- status: org_status,
86
- type: 'Organization',
87
- brands: {},
88
- };
89
- }
90
-
91
- if (!result[org_id].brands[brand_id]) {
92
- result[org_id].brands[brand_id] = {
71
+ org_status,
93
72
  brand_id,
94
73
  brand_name,
95
- status: brand_status,
96
- type: 'Brand',
97
- schools: [],
98
- };
74
+ brand_status,
75
+ school_id,
76
+ school_name,
77
+ school_location,
78
+ school_status,
79
+ } = row;
80
+
81
+ if (!result[org_id]) {
82
+ result[org_id] = {
83
+ org_id,
84
+ org_name,
85
+ org_address,
86
+ status: org_status,
87
+ type: 'Organization',
88
+ brands: {},
89
+ };
90
+ }
91
+
92
+ if (!result[org_id].brands[brand_id]) {
93
+ result[org_id].brands[brand_id] = {
94
+ brand_id,
95
+ brand_name,
96
+ status: brand_status,
97
+ type: 'Brand',
98
+ schools: [],
99
+ };
100
+ }
101
+
102
+ result[org_id].brands[brand_id].schools.push({
103
+ school_id,
104
+ school_name,
105
+ school_location,
106
+ status: school_status,
107
+ type: 'School',
108
+ });
99
109
  }
100
-
101
- result[org_id].brands[brand_id].schools.push({
102
- school_id,
103
- school_name,
104
- school_location,
105
- status: school_status,
106
- type: 'School',
107
- });
110
+ return Object.values(result).map((org: any) => ({
111
+ ...org,
112
+ brands: Object.values(org.brands),
113
+ }));
114
+ } else {
115
+ const orgDetails = await this.dataSource.createQueryBuilder();
116
+
117
+ orgDetails
118
+ .select(['*'])
119
+ .from('cr_organization', 'org')
120
+ .where('org.id = :orgId', { orgId: currentORGLevel_id });
121
+
122
+ const orgResult = await orgDetails.getRawOne();
123
+
124
+ return [
125
+ {
126
+ org_id: currentORGLevel_id,
127
+ org_name: orgResult.name,
128
+ org_address: orgResult.address,
129
+ status: orgResult.status,
130
+ type: orgResult.type || 'Organization',
131
+ brands: [],
132
+ },
133
+ ];
108
134
  }
109
-
110
- return Object.values(result).map((org: any) => ({
111
- ...org,
112
- brands: Object.values(org.brands),
113
- }));
114
135
  } else {
115
136
  const brnMappings = await this.dataSource
116
137
  .createQueryBuilder()