Page MenuHomeIn-Portal Phabricator

D392.id957.diff
No OneTemporary

File Metadata

Created
Tue, Oct 14, 1:35 AM

D392.id957.diff

Index: core/units/helpers/deployment_helper.php
===================================================================
--- core/units/helpers/deployment_helper.php
+++ core/units/helpers/deployment_helper.php
@@ -521,6 +521,7 @@
$this->out('Upgrading Database ... ', true);
foreach ($this->revisionSqls as $revision => $sqls) {
+ $this->toLog(PHP_EOL . $this->revisionTitles[$revision]);
echo PHP_EOL . $this->colorText($this->revisionTitles[$revision], 'gray', true) . PHP_EOL; // 'Processing DB Revision: #' . $revision . ' ... ';
$sqls = str_replace("\r\n", "\n", $sqls); // convert to linux line endings
@@ -538,14 +539,28 @@
continue;
}
elseif ( $sql ) {
- $this->toLog($sql . ' ... ', false);
+ $this->toLog($sql . '; ... ', false);
$escaped_sql = $this->isCommandLine ? $sql : kUtil::escape($sql);
echo mb_substr(trim(preg_replace('/(\n|\t| )+/is', ' ', $escaped_sql)), 0, self::SQL_TRIM_LENGTH) . ' ... ';
+ $query_start_time = time();
$this->Conn->Query($sql);
+ $query_end_time = time();
+ $formatted_query_duration = $this->formatDuration($query_end_time - $query_start_time);
$this->toLog('OK (' . $this->Conn->getAffectedRows() . ')');
- $this->displayStatus('OK (' . $this->Conn->getAffectedRows() . ')');
+ $this->toLog(sprintf(
+ 'Duration: %s (from %s to %s)',
+ $formatted_query_duration,
+ date('Y-m-d H:i:s', $query_start_time),
+ date('Y-m-d H:i:s', $query_end_time)
+ ));
+
+ $this->displayStatus(sprintf(
+ 'OK (%s) *Time*: %s',
+ $this->Conn->getAffectedRows(),
+ $formatted_query_duration
+ ));
}
}
}
@@ -565,6 +580,29 @@
}
/**
+ * Formats duration.
+ *
+ * @param integer $seconds Seconds.
+ *
+ * @return string
+ */
+ protected function formatDuration($seconds)
+ {
+ $real_seconds = $seconds % 60;
+ $minutes = $seconds - $real_seconds;
+
+ $ret = array();
+
+ if ( $minutes ) {
+ $ret[] = ($minutes / 60) . 'm';
+ }
+
+ $ret[] = $real_seconds . 's';
+
+ return implode(' ', $ret);
+ }
+
+ /**
* Error handler for sql errors.
*
* @param integer $code Error code.

Event Timeline