rez_core 2.1.73 → 2.1.75

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.73",
3
+ "version": "2.1.75",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -34,15 +34,11 @@ export class SchoolRepository {
34
34
  .andWhere('urm.level_type = :levelType', { levelType: 'ORG' })
35
35
  .getRawMany();
36
36
 
37
- console.log('hasOrgAccess before', hasOrgAccess);
38
-
39
37
  let currentORGLevel_id = hasOrgAccess[0]?.urm_level_id;
40
38
  if (hasOrgAccess[0].urm_level_id == 1) {
41
39
  currentORGLevel_id = org_id;
42
40
  }
43
41
 
44
- console.log('currentORGLevel_id', currentORGLevel_id);
45
-
46
42
  if (hasOrgAccess.length > 0) {
47
43
  const schools = await this.dataSource
48
44
  .createQueryBuilder()
@@ -65,58 +61,77 @@ export class SchoolRepository {
65
61
  .where('org.id = :orgId', { orgId: currentORGLevel_id })
66
62
  .getRawMany();
67
63
 
68
- console.log('schools', schools);
69
-
70
- const result = {};
71
- for (const row of schools) {
72
- const {
73
- org_id,
74
- org_name,
75
- org_address,
76
- org_status,
77
- brand_id,
78
- brand_name,
79
- brand_status,
80
- school_id,
81
- school_name,
82
- school_location,
83
- school_status,
84
- } = row;
85
-
86
- if (!result[org_id]) {
87
- result[org_id] = {
64
+ if (schools.length > 0) {
65
+ const result = {};
66
+ for (const row of schools) {
67
+ const {
88
68
  org_id,
89
69
  org_name,
90
70
  org_address,
91
- status: org_status,
92
- type: 'Organization',
93
- brands: {},
94
- };
95
- }
96
-
97
- if (!result[org_id].brands[brand_id]) {
98
- result[org_id].brands[brand_id] = {
71
+ org_status,
99
72
  brand_id,
100
73
  brand_name,
101
- status: brand_status,
102
- type: 'Brand',
103
- schools: [],
104
- };
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
+ });
105
109
  }
106
-
107
- result[org_id].brands[brand_id].schools.push({
108
- school_id,
109
- school_name,
110
- school_location,
111
- status: school_status,
112
- type: 'School',
113
- });
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
+ ];
114
134
  }
115
-
116
- return Object.values(result).map((org: any) => ({
117
- ...org,
118
- brands: Object.values(org.brands),
119
- }));
120
135
  } else {
121
136
  const brnMappings = await this.dataSource
122
137
  .createQueryBuilder()
@@ -140,7 +140,7 @@ export class ListMasterItemService {
140
140
  } catch (error) {
141
141
  errors.push({
142
142
  row: i,
143
- error: [
143
+ errors: [
144
144
  {
145
145
  field: 'name',
146
146
  message: