3. Exploitation - PurgeTracking 

Page / - last modified by Assala Chmiti on 2022/07/29 16:09 

PurgeTracking 
last modified by Assala Chmiti
on 2022/07/29 16:09

Table of Contents
Introduction:
Explaining the connector format:
Example Format:
Use:
When the purge is executed?:

Contents
•	Introduction:
•	Explaining the connector format:
•	PurgeTracking
•	Example Format:
•	Use:
•	When the purge is executed?:
•	PurgeTracking
Introduction:
"PurgeTracking" is a connector that allows administrators to delete all unused Tracking from the database by specifying some parameters to include in the format file.
The need to use such a connector is to reach the database availability and scalability by allegiance the size of each table relating to the Tracking process knowing that it takes a lot of memory if not resolved.
Our connector's presentation is going to be described in details in 3 parts :
 1.	 Parameters 
•	format
 2.	 Use
             
Explaining the connector format:
The parameters used in this connector are : 
•	iXPurgeTrk: root node where should be specified 2 attributes :
•	"Retention": it refers to the number of days, if passed it should delete all Tracking created before that date.
•	"stopTime": attribute showing numbers of minutes to stop PurgeTracking. Passing this time, the connector should stop working and go to the next connector of the current scenario.  
•	iXToDelete: a node where we add all tracking to be deleted in PurgeTracking. To add tracking to be deleted, we should follow these steps :
•	Add a node to the iXToDelete node.
•	Put the Tracking Type as the node name.
•	Specify Tracking Status type ID in the "StatusType" attribute. If it equals "*", it means we want to delete all Tracking regardless of Status. we can also put multiple status by separating them by comma, example : "StatusType" = "1,5,13,56".
•	iXToForbid: an XML node to put trackings to not delete while executing PurgeTracking. It works similar to iXToDelete.
                      
Example Format:
Below, we find an example showing a format file to delete trackings following some criteria :
•	We want to delete all trackings of type 'Order' that its date passed 30 days. The connector will delete automatically all subtrackings of 'Order'  selected by a SQL query, in this case, we should be careful and mention all trackings forbidden to be deleted. The trackings to not be deleted are:
•	Tracking 'Order' with StatusType 1 and 12.
•	Tracking 'OrderLine' with StatusType 1.
•	All Status types for the tracking 'Product_Base'.
•	We set a stopTime of 7 hours. If PurgeTracking started at 1:00PM it should stop at 8:00PM, even if it didn't delete all tracking wanted.
<?xml version="1.0" encoding="windows-1250"?>

<iXDoc>
<iXPurgeTrk Retention = "30" stopTime="7">

 <iXToDelete>
  <Order StatusType="*"></Order>
 </iXToDelete>

 <iXToForbid>
  <Order StatusType="1,12"></Order>
  <OrderLine StatusType="1"></OrderLine>
  <Product_Base StatusType = "*"></Product_Base>
 </iXToForbid>

</iXPurgeTrk>
</iXDoc>
Use:
As explained before, the PurgeTracking connector is used to delete tracking and its subtrackings by writing the format file.
Practically, the delete of tracking that has a certain ID (eg.  TrkID = 1234 And TrackingType = 'OrderLine'), will generate all following deletes on this order :
 1.	Delete Tracking file from 'TrackingFile' table where TrkID=1234
 2.	Delete Tracking environement from 'TrackingEnv' table where TrkID = 1234
 3.	Delete all Tracking Links from "TrackingLink' table where TrkID = 1234 or ParentTrkID = 1234
 4.	Delete Tracking from '_OrderLine' table where TrkID = 1234
 5.	Finally, delete Tracking from 'Tracking' Table where TrkID =1234
In addition to that, the connector makes the execution in the current environment and its sub-environments. For example, if there is an environnement (EnvID = 1) which has 2 sub-environments ( EnvID = 2 and EnvID = 3), and we start 'PurgeTracking' in EnvID = 1, the connector will be automaticly executed in environments  1,2 and 3.  
When the purge is executed?:
As we can see in the format file, the tracking lines that are deleted are based on their status type. So, to delete the tracking lines, consultants needs only to set the status type of the tracking table lines that they want to delete to '99'. The value 99 is the one that corresponds to the status 'to be purged' in the database.
This step of changing the status type is necessary when a tracking table is no longer needed and the consultants are the ones that knows what are the tracking tables that should be deleted. The deletion will start once the tracking lines have a correct status type(with the value '99') mentionned in the iXToDelete tag in the format file and have a creation date that surpass the retention date from today's date.
This connector should only be executed by the iXPath members.
The retention attribute in the format file for the iXPurgeTrk tag is set to the value 180 (6 months) in the SIM and PROD server.