rez_core 3.1.122 → 3.1.124

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": "3.1.122",
3
+ "version": "3.1.124",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -59,6 +59,11 @@ export class PopulateMetaService {
59
59
  ];
60
60
  const entityTypeToNewIdMap = new Map<string, number>();
61
61
 
62
+ const getStatus = await this.dataSource.query(
63
+ `SELECT * FROM cr_list_master_items WHERE organization_id = ${organization_id} AND code = "STATUS_ACTIVE"`,
64
+ );
65
+ const status = getStatus[0]?.id ? getStatus[0].id : 'ACTIVE';
66
+
62
67
  // Step 1: Insert basic metadata tables
63
68
  for (const table of metadataTables) {
64
69
  const factoryData = await this.dataSource.query(
@@ -78,6 +83,7 @@ export class PopulateMetaService {
78
83
  level_id: organization_id,
79
84
  is_unique: rest.is_unique == 1 ? true : false,
80
85
  required: rest.required == 1 ? true : false,
86
+ status: status,
81
87
  }),
82
88
  );
83
89
  } else {
@@ -87,6 +93,7 @@ export class PopulateMetaService {
87
93
  organization_id,
88
94
  level_type: 'ORG',
89
95
  level_id: organization_id,
96
+ status: status,
90
97
  }),
91
98
  );
92
99
  }
@@ -119,29 +119,6 @@ export class PopulateWorkflowService extends EntityServiceImpl {
119
119
  }
120
120
  }
121
121
 
122
- const defaultEntity = await this.dataSource.query(
123
- `SELECT * FROM eth_entity WHERE organization_id = -1 AND level_type = 'ORG' AND level_id = -1 AND entity_type = 'ENT'`,
124
- );
125
-
126
- const defaultEntityData = defaultEntity[0];
127
-
128
- defaultEntityData.organization_id = organization_id;
129
- defaultEntityData.level_id = organization_id;
130
-
131
- await this.dataSource.query(
132
- `INSERT INTO eth_entity (entity_type, name, status, code, enterprise_id, organization_id, level_id, level_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
133
- [
134
- defaultEntityData.entity_type,
135
- defaultEntityData.name,
136
- defaultEntityData.status,
137
- defaultEntityData.code,
138
- defaultEntityData.enterprise_id,
139
- organization_id,
140
- organization_id,
141
- defaultEntityData.level_type,
142
- ],
143
- );
144
-
145
122
  const workflowTables = [
146
123
  { table: 'cr_workflow', entityType: 'WRFW', service: 'workflowService' },
147
124
  {
@@ -64,8 +64,25 @@ export class WorkflowMetaService extends EntityServiceImpl {
64
64
  });
65
65
 
66
66
  if (!currentStage) {
67
- // If no current stage found, return null
68
- return null;
67
+ // Fetch the latest stage movement for the given entity
68
+ const latestMovement = await this.stageMovementRepo.findOne({
69
+ where: {
70
+ mapped_entity_type,
71
+ mapped_entity_id,
72
+ },
73
+ order: { id: 'DESC' }, // Get the most recent movement
74
+ });
75
+
76
+ if (!latestMovement) return null;
77
+
78
+ const getGroupName = await this.dataSource.query(
79
+ `SELECT name FROM cr_wf_stage_group WHERE id = ${latestMovement?.stage_group_id}`,
80
+ );
81
+
82
+ return {
83
+ ...latestMovement,
84
+ stage_group_name: getGroupName[0]?.name,
85
+ };
69
86
  }
70
87
 
71
88
  // get group name for the current stage