From 184d2c2cba82ed7310d29be24d078c575c840c04 Mon Sep 17 00:00:00 2001 From: Chase Tucker Date: Wed, 9 Jul 2025 10:58:58 -0700 Subject: [PATCH] cache the TW type list --- LSL2/STPROC/SCAN_SERVICES.txt | 65 ++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/LSL2/STPROC/SCAN_SERVICES.txt b/LSL2/STPROC/SCAN_SERVICES.txt index 1b79b28..f392dc4 100644 --- a/LSL2/STPROC/SCAN_SERVICES.txt +++ b/LSL2/STPROC/SCAN_SERVICES.txt @@ -1711,7 +1711,6 @@ Service ConvertMVScanToJSON(ScanID, mvScan, itemURL) SRP_JSON(objScan, 'SetValue', 'ID', @ID, 'String') SRP_JSON(objScan, 'SetValue', 'type', {SCAN_TYPE}, 'String') SRP_JSON(objScan, 'SetValue', 'action', {ACTION}, 'String') - SRP_JSON(objScan, 'SetValue', 'testRunTypeId', {TEST_RUN_TYPE_ID}, 'Integer') SRP_JSON(objScan, 'SetValue', 'acceptable', {ACCEPTABLE}, 'Boolean') SRP_JSON(objScan, 'SetValue', 'notAcceptableReason', {NOT_ACCEPTABLE_REASON}, 'String') @@ -1768,23 +1767,55 @@ Service ConvertMVScanToJSON(ScanID, mvScan, itemURL) SRP_JSON(hTWLotArray, 'Release') end SRP_JSON(objScan, 'SetValue', 'testRunTypeId', {TEST_RUN_TYPE_ID}, 'Integer') + // TestRun Type Option Array - TestRunTypeList = Test_Run_Services('GetAllTestRunTypes') - If SRP_JSON(hTestRunTypeArray, 'New', 'Array') then - For each TestRunTypeId in TestRunTypeList<1> using @VM setting fPos - hTestRunTypeObj = '' - If SRP_JSON(hTestRunTypeObj, 'New', 'Object') then - SRP_JSON(hTestRunTypeObj, 'SetValue', 'testRunTypeId', TestRunTypeId, 'Number') - SRP_JSON(hTestRunTypeObj, 'SetValue', 'testRunTypeName', TestRunTypeList<2, fPos>, 'String') - SRP_JSON(hTestRunTypeArray, 'Add', hTestRunTypeObj) - SRP_JSON(hTestRunTypeObj, 'Release') - end else - Abort = True$ + twRunTypeListCacheKey$ = 'TW_RUN_TYPE_OPTIONS' + jsonField$ = 1 + lastTickField$ = 2 + oneHourTicks$ = 3600000 + + TestRunTypeOptionsJson = Xlate('APP_INFO', twRunTypeListCacheKey$, jsonField$, 'X') + LastTick = Xlate('APP_INFO', 'TW_RUN_TYPE_OPTIONS', lastTickField$, 'X') + TickDiff = oneHourTicks$ + oneHourTicks$ + ParsingResponse = '' + If TestRunTypeOptionsJson NE '' and LastTick NE '' and Num(LastTick) then + TickDiff = GetTickCount() - LastTick + + If TestRunTypeOptionsJson NE '' and TickDiff LT oneHourTicks$ then + ParsingResponse = SRP_JSON(hTRTypeOpts, 'Parse', TestRunTypeOptionsJson) + If ParsingResponse EQ '' then + SRP_JSON(objJSONScan, 'Set', 'testRunTypeOptions', hTRTypeOpts) + end + end + end + + + If LastTick EQ '' or Num(LastTick) EQ False$ or TestRunTypeOptionsJson EQ '' or TickDiff GE oneHourTicks$ or ParsingResponse NE '' then + If SRP_JSON(hTestRunTypeArray, 'New', 'Array') then + TestRunTypeList = Test_Run_Services('GetAllTestRunTypes') + For each TestRunTypeId in TestRunTypeList<1> using @VM setting fPos + hTestRunTypeObj = '' + If SRP_JSON(hTestRunTypeObj, 'New', 'Object') then + SRP_JSON(hTestRunTypeObj, 'SetValue', 'testRunTypeId', TestRunTypeId, 'Number') + SRP_JSON(hTestRunTypeObj, 'SetValue', 'testRunTypeName', TestRunTypeList<2, fPos>, 'String') + SRP_JSON(hTestRunTypeArray, 'Add', hTestRunTypeObj) + SRP_JSON(hTestRunTypeObj, 'Release') + end else + Abort = True$ + end + Until Abort + Next TestRunTypeId + If Abort EQ False$ then + SRP_JSON(objJSONScan, 'Set', 'testRunTypeOptions', hTestRunTypeArray) + TRTypeListJson = SRP_JSON(hTestRunTypeArray, 'Stringify', 'Fast') + LastTick = GetTickCount() + + twRunTypeOptionsRec = '' + twRunTypeOptionsRec = TRTypeListJson + twRunTypeOptionsRec = LastTick + + Database_Services('WriteDataRow', 'APP_INFO', twRunTypeListCacheKey$, twRunTypeOptionsRec, True$, False$, False$) end - Until Abort - Next TestRunTypeId - If Abort EQ False$ then - SRP_JSON(objJSONScan, 'Set', 'testRunTypeOptions', hTestRunTypeArray) end SRP_JSON(hTestRunTypeArray, 'Release') end @@ -2350,3 +2381,5 @@ return + +