Skip to content

Commit 281d8df

Browse files
committed
FEAT: added globals check to corresponding methods
1 parent 19ace35 commit 281d8df

File tree

1 file changed

+11
-135
lines changed

1 file changed

+11
-135
lines changed

MDX2JSON/Utils.cls

Lines changed: 11 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ ClassMethod WriteJSONfromMDX(MDX As %String, Timeout As %Integer = 0) As %Status
6060
Set tSC = $$$OK
6161
#dim RS As MDX2JSON.ResultSet
6262

63-
set start = $PIECE($NOW(),",",2)
64-
6563
set RS = ..GetResultSet(MDX, .tSC)
6664
set cube = ##class(%DeepSee.Utils).%IsCubeCompound(RS.%Cube) // check if cube is compound type
6765
return:$$$ISERR(tSC) tSC
@@ -78,6 +76,10 @@ ClassMethod WriteJSONfromMDX(MDX As %String, Timeout As %Integer = 0) As %Status
7876

7977
set obj = RS.ToProxyObject(.tSC)
8078
return:$$$ISERR(tSC) tSC
79+
80+
// check if audit global hold something and execute it
81+
try {xecute ^DeepSee.AuditQueryCode} catch {}
82+
8183
$$$DynObjToJSON(obj)
8284

8385
}else{ // if cube is not compound execute the query in usual way
@@ -87,15 +89,12 @@ ClassMethod WriteJSONfromMDX(MDX As %String, Timeout As %Integer = 0) As %Status
8789

8890
set obj = RS.ToProxyObject(.tSC)
8991
return:$$$ISERR(tSC) tSC
90-
$$$DynObjToJSON(obj)
91-
}
9292

93-
set stop = $PIECE($NOW(),",",2)
93+
// check if audit global hold something and execute it
94+
try {xecute ^DeepSee.AuditQueryCode} catch {}
9495

95-
set executionTime = stop - start
96-
set query = RS.%GetQuery()
97-
98-
set audit = ..WriteAudit(MDX, "query", executionTime)
96+
$$$DynObjToJSON(obj)
97+
}
9998

10099
return $$$OK
101100
}
@@ -317,7 +316,6 @@ ClassMethod GetDataSource(pDataSource As %String)
317316

318317
set st = $$$OK
319318
try {
320-
set start = $PIECE($NOW(),",",2)
321319

322320
if ($FIND(pDataSource, ".pivot") = ($LENGTH(pDataSource) + 1) && pDataSource '="") {
323321
set st = ..OpenPivotByName(pDataSource, .dataSource)
@@ -329,13 +327,6 @@ ClassMethod GetDataSource(pDataSource As %String)
329327
set dataSource.mdx = mdx
330328
}
331329
set st = ##class(%ZEN.Auxiliary.jsonProvider).%ObjectToJSON(dataSource, .out)
332-
333-
set stop = $PIECE($NOW(),",",2)
334-
335-
set executionTime = stop - start
336-
337-
set audit = ..WriteAudit(pDataSource, "pivot", executionTime)
338-
339330

340331
}
341332

@@ -426,22 +417,16 @@ ClassMethod GetWidgetsList(pDashName As %String) As %Status
426417
ClassMethod GetDashboard(pDashName As %String) As %Status
427418
{
428419
try {
429-
set start = $PIECE($NOW(),",",2)
430-
431420
set st = ##class(MDX2JSON.DashboardFilters).OpenDashboardByName(pDashName, .dash)
432421
return:($$$ISERR(st)) st
433422

434423
set st = ##class(MDX2JSON.DashboardFilters).WidgetsToProxyObject(dash, .widgetlist)
435424
return:($$$ISERR(st)) st
436425
w "" // weird hack required for 15.3
437-
438-
set stop = $PIECE($NOW(),",",2)
439-
440-
set executionTime = stop - start
441-
442-
set audit = ..WriteAudit(pDashName, "dashboard", executionTime)
443-
444426

427+
// check if audit global hold something and execute it
428+
try {xecute ^DeepSee.AuditCode} catch {}
429+
445430
$$$DynObjToJSON(widgetlist)
446431
} catch ex {
447432
set st = ex.AsStatus()
@@ -584,115 +569,6 @@ ClassMethod CreateAddonClass(Class As %Dictionary.CacheClassname) As %Status
584569
quit classObj.%Save()
585570
}
586571

587-
ClassMethod WriteAudit(element, elementName, executionTime = 0) As %Status
588-
{
589-
set st = $$$OK
590-
591-
set ^CallAmount($INCREMENT(^CallAmount)) = 1
592-
593-
594-
if ^AuditState = "on"
595-
{
596-
if elementName = "dashboard"
597-
{
598-
set ^MyBIAuditLogDash($INCREMENT(^MyBIAuditLogDash)) = $lb($ZDT($H,3), $USERNAME, element, executionTime)
599-
}
600-
elseif elementName = "pivot"
601-
{
602-
set ^MyBIAuditLogPivot($INCREMENT(^MyBIAuditLogPivot)) = $lb($ZDT($H,3), $USERNAME, element, executionTime)
603-
}
604-
elseif elementName = "query"
605-
{
606-
set ^MyBIAuditLogQuery($INCREMENT(^MyBIAuditLogQuery)) = $lb($ZDT($H,3), $USERNAME, element, executionTime)
607-
}
608-
609-
610-
}else{
611-
612-
quit st
613-
}
614-
615-
616-
return st
617-
}
618-
619-
ClassMethod ReadAudit(metricName) As %Status
620-
{
621-
set st = $$$OK
622-
623-
if ^AuditState = "on"
624-
{
625-
if metricName = "query"
626-
{
627-
628-
set len = $order(^MyBIAuditLogQuery(""),-1)
629-
for n=1:1:len
630-
{
631-
set log = $Get(^MyBIAuditLogQuery(n))
632-
write !
633-
write "Element call time: ", $lg(log, 1), !
634-
write "User: ", $lg(log, 2), !
635-
write "Execution time in sec.: ", $lg(log, 4), !
636-
write "Query: ", $lg(log, 3), !
637-
}
638-
}
639-
elseif metricName = "pivot"
640-
{
641-
642-
set len = $order(^MyBIAuditLogPivot(""),-1)
643-
for n=1:1:len
644-
{
645-
set log = $Get(^MyBIAuditLogPivot(n))
646-
write !
647-
write "Element call time: ", $lg(log, 1), !
648-
write "User: ", $lg(log, 2), !
649-
write "Execution time in sec.: ", $lg(log, 4), !
650-
write "Pivot: ", $lg(log, 3), !
651-
}
652-
}
653-
elseif metricName = "dashboard"
654-
{
655-
set len = $order(^MyBIAuditLogDash(""),-1)
656-
for n=1:1:len
657-
{
658-
set log = $Get(^MyBIAuditLogDash(n))
659-
write !
660-
write "Element call time: ", $lg(log, 1), !
661-
write "User: ", $lg(log, 2), !
662-
write "Execution time in sec.: ", $lg(log, 4), !
663-
write "Dashboard: ", $lg(log, 3), !
664-
}
665-
}
666-
}
667-
668-
quit st
669-
}
670-
671-
ClassMethod AuditStateSwitch(auditstate = 0) As %Status
672-
{
673-
set st = $$$OK
674-
675-
if auditstate = 0
676-
{
677-
set ^AuditState = "off"
678-
679-
}else{
680-
681-
set ^AuditState = "on"
682-
}
683-
684-
write "Audit state: " _ ^AuditState
685-
}
686-
687-
ClassMethod AuditKill() As %Status
688-
{
689-
kill ^MyBIAuditLogDash
690-
kill ^MyBIAuditLogPivot
691-
kill ^MyBIAuditLogQuery
692-
693-
write "All globals are cleaned"
694-
}
695-
696572
/// Add new widgets and edit existing ones directly from DeepSeeWeb
697573
/// it takes widget name(key) as unique identifier as string, dashboard name as string
698574
/// and object with parameters as zen.proxyObject

0 commit comments

Comments
 (0)