[us-commits] r2743 - in trunk: programs/us_xpn_viewer sql

svn at svn.aucsolutions.com svn at svn.aucsolutions.com
Sun Apr 28 21:44:18 MDT 2019


Author: alexey
Date: 2019-04-29 03:44:16 +0000 (Mon, 29 Apr 2019)
New Revision: 2743

Modified:
   trunk/programs/us_xpn_viewer/us_xpn_viewer_gui.cpp
   trunk/sql/us3_autoflow_procs.sql
Log:
Update on job reattachement



Modified: trunk/programs/us_xpn_viewer/us_xpn_viewer_gui.cpp
===================================================================
--- trunk/programs/us_xpn_viewer/us_xpn_viewer_gui.cpp	2019-04-28 17:43:16 UTC (rev 2742)
+++ trunk/programs/us_xpn_viewer/us_xpn_viewer_gui.cpp	2019-04-29 03:44:16 UTC (rev 2743)
@@ -1066,6 +1066,7 @@
 
    reset();
    adjustSize();
+
 }
 
 
@@ -1417,7 +1418,6 @@
 // Load Optima raw (.postgres) data
 bool US_XpnDataViewer::load_xpn_raw_auto( )
 {
-
   bool status_ok = false;
 
   if ( in_reload_data_init )             // If already doing a reload,
@@ -1439,10 +1439,12 @@
 
       qDebug() << "RunID_to_retrieve 1: " << RunID_to_retrieve;
 
+
+      // //Test
       // ElapsedTimeOffset = read_timeElapsed_offset();
-      // qDebug() << "Elapsed Time Offset: " << ElapsedTimeOffset;
+      // qDebug() << "TEST: Elapsed time from autoflow: " << ElapsedTimeOffset;
+
       
-
       // runInfo.clear();
       
       //xpn_data->scan_runs( runInfo );                          // ALEXEY initial query (for us_comproject needs to be based on ExpId ) 
@@ -1581,11 +1583,14 @@
 			     tr( "Read protocol: Could not connect to database \n" ) + db->lastError() );
        return time_offset;
      }
-
+   
    QStringList qry;
-   qry << "read_autoflow_times"
+   qry << "read_autoflow_times_mod"
        << RunID_to_retrieve;
-   
+
+   // //Test only
+   // qry << "read_autoflow_times_mod_test";
+     
    time_offset = db->functionQuery( qry );
 
    return time_offset;
@@ -2255,6 +2260,7 @@
 // Load Optima raw (.postgres) data
 void US_XpnDataViewer::load_xpn_raw( )
 {
+
    // Ask for data directory
    QString dbhost    = xpnhost;
    int     dbport    = xpnport.toInt();

Modified: trunk/sql/us3_autoflow_procs.sql
===================================================================
--- trunk/sql/us3_autoflow_procs.sql	2019-04-28 17:43:16 UTC (rev 2742)
+++ trunk/sql/us3_autoflow_procs.sql	2019-04-29 03:44:16 UTC (rev 2743)
@@ -208,7 +208,7 @@
 END$$
 
 
--- Update autoflow record with Optima's RunID
+-- Update autoflow record with Optima's RunID (ONLY once, first time )
 DROP PROCEDURE IF EXISTS update_autoflow_runid_starttime$$
 CREATE PROCEDURE update_autoflow_runid_starttime ( p_personGUID    CHAR(36),
                                          	 p_password      VARCHAR(80),
@@ -309,10 +309,99 @@
 
   SELECT TIMESTAMPDIFF( SECOND, runStarted, NOW() ) 
   INTO l_sec_difference 
-  FROM autoflow WHERE runID = p_runID;
+  FROM autoflow WHERE runID = p_runID AND runStarted IS NOT NULL;
 
 
   RETURN( l_sec_difference );
 
 END$$
 
+
+
+----  get initial elapsed time upon reattachment ----------------------------- 
+DROP FUNCTION IF EXISTS read_autoflow_times_mod$$
+CREATE FUNCTION read_autoflow_times_mod ( p_personGUID CHAR(36),
+                                       	p_password   VARCHAR(80), 
+				       	p_runID      INT )
+                                       
+  RETURNS INT
+  READS SQL DATA
+
+BEGIN
+  DECLARE count_records INT;
+  DECLARE l_sec_difference INT;
+  DECLARE cur_runStarted TIMESTAMP; 
+  	  
+  SET l_sec_difference = 0;
+
+  CALL config();
+  SET @US3_LAST_ERRNO = @OK;
+  SET @US3_LAST_ERROR = '';
+
+  SELECT     COUNT(*)
+  INTO       count_records
+  FROM       autoflow
+  WHERE      runID = p_runID;
+
+  SELECT     runStarted
+  INTO       cur_runStarted
+  FROM       autoflow
+  WHERE      runID = p_runID;
+  
+  IF ( verify_user( p_personGUID, p_password ) = @OK ) THEN
+    IF ( count_records > 0 ) THEN
+      IF ( cur_runStarted IS NOT NULL ) THEN 
+        
+	SELECT TIMESTAMPDIFF( SECOND, curr_runStarted, NOW() ) 
+ 	INTO l_sec_difference; 
+
+      END IF;	
+    END IF;
+  END IF;
+    
+  RETURN( l_sec_difference );
+
+END$$
+
+----  TEST: TO BE DELETED: get initial elapsed time upon reattachment ----------------------------- 
+DROP FUNCTION IF EXISTS read_autoflow_times_mod_test$$
+CREATE FUNCTION read_autoflow_times_mod_test ( p_personGUID CHAR(36),
+                                       	     p_password   VARCHAR(80) ) 
+				       	
+                                       
+  RETURNS INT
+  READS SQL DATA
+
+BEGIN
+  DECLARE count_records INT;
+  DECLARE l_sec_difference INT;
+  DECLARE cur_runStarted TIMESTAMP; 
+  	  
+  SET l_sec_difference = 0;
+
+  CALL config();
+  SET @US3_LAST_ERRNO = @OK;
+  SET @US3_LAST_ERROR = '';
+
+  SELECT     COUNT(*)
+  INTO       count_records
+  FROM       autoflow;
+ 
+  SELECT     created
+  INTO       cur_runStarted
+  FROM       autoflow LIMIT 1;
+   
+  IF ( verify_user( p_personGUID, p_password ) = @OK ) THEN
+    IF ( count_records > 0 ) THEN
+      IF ( cur_runStarted IS NOT NULL ) THEN 
+        
+	SELECT TIMESTAMPDIFF( SECOND, cur_runStarted, NOW() ) 
+ 	INTO l_sec_difference; 
+  	
+      END IF;	
+    END IF;
+  END IF;
+    
+  RETURN( l_sec_difference );
+
+END$$



More information about the us-commits mailing list