Commit b13d92a1 authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Added 'setTotalBlocks()' and 'updateProcessedBlocks()' methods.

parent d56895fe
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -550,6 +550,42 @@ class DbConnector(object):
                if not conn.closed:
                    conn.rollback()
                    
    def setTotalBlocks(self, jobId, totalBlocks):
        """
        Sets the job 'total_blocks' parameter
        for a data retrieve operation.
        """
        with self.getConnection() as conn:
            try:
                cursor = conn.cursor(cursor_factory = RealDictCursor)
                cursor.execute("""
                    UPDATE job SET total_blocks = %s
                    WHERE job_id = %s;
                    """,
                    (totalBlocks, jobId,))
                conn.commit()
            except Exception as e:
                if not conn.closed:
                    conn.rollback()
                    
    def updateProcessedBlocks(self, jobId, processedBlocks):
        """
        Updates the job 'processed_blocks' parameter
        for a data retrieve operation.
        """
        with self.getConnection() as conn:
            try:
                cursor = conn.cursor(cursor_factory = RealDictCursor)
                cursor.execute("""
                    UPDATE job SET processed_blocks = %s
                    WHERE job_id = %s;
                    """,
                    (processedBlocks, jobId,))
                conn.commit()
            except Exception as e:
                if not conn.closed:
                    conn.rollback()

    def setResults(self, jobId, results):
        """Sets the job 'results' parameter."""
        with self.getConnection() as conn: