New perf dashboard should have an ability to search commits by a keyword
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Oct 2014 23:46:45 +0000 (23:46 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Oct 2014 23:46:45 +0000 (23:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137675

Reviewed by Geoffrey Garen.

/api/commits/ now accepts query parameters to search a commit by a keyword. Its output format changed to
include "authorEmail" and "authorName" directly as columns instead of including an "author" object.
This API change allows fetch_commits_between to generate results without processing Postgres query results.

In the front end side, we've added a search pane in pane controller, and the interactive chart component
now has a concept of highlighted items which is used to indicate commits found by the search pane.

* public/api/commits.php:
(main): Extract query parameters: keyword, from, and to and use that to fetch appropriate commits.
(fetch_commits_between): Moved some code from main. Now takes a search term as the third argument.
We look for a commit if its author name or email contains the keyword or if its revision matches the keyword.
(format_commit): Renamed from format_commits. Now only formats one commit.

* public/include/db.php:
(Database::query_and_fetch_all): Now returns array() when the query results is empty (instead of false).

* public/v2/app.css: Renamed .close-button to .icon-button since it's used by a search button as well.

* public/v2/app.js:
(App.Pane.searchCommit): Added. Finds the commits by a search term and assigns 'highlightedItems',
which is a hash table that contains highlighted items' measurements' ids as keys.
(App.PaneController.actions.toggleSearch): Toggles the visibility of the search pane. Also sets
the default commit repository.
(App.PaneController.actions.searchCommit): Delegates the work to App.Pane.searchCommit.
(App.InteractiveChartComponent._constructGraphIfPossible): Fixed a bug that we weren't removing old this._dots.
Added the code to initialize this._highlights.
(App.InteractiveChartComponent._updateDimensionsIfNeeded): Updates dimensions of highlight lines.
(App.InteractiveChartComponent._updateHighlightPositions): Added. Ditto.
(App.InteractiveChartComponent._highlightedItemsChanged): Adds vertical lines for highlighted items and deletes
the existing lines for the old highlighted items.
(App.CommitsViewerComponent.commitsChanged): Updated the code per JSON API change mentioned above.
Also fixed a bug that the code tries to update the commits viewer even if the viewer had already been destroyed.

* public/v2/chart-pane.css: Added style for the search pane and the search button.

* public/v2/data.js: Turned FetchCommitsForTimeRange into a class: CommitLogs.
(CommitLogs): Added.
(CommitLogs.fetchForTimeRange): Renamed from FetchCommitsForTimeRange. Takes a search term as an argument.
(CommitLogs._cachedCommitsBetween): Extracted from FetchCommitsForTimeRange.
(CommitLogs._cacheConsecutiveCommits): Ditto.
(FetchCommitsForTimeRange._cachedCommitsByRepository): Deleted.
(Measurement.prototype.commitTimeForRepository): Extracted from formattedRevisions.
(Measurement.prototype.formattedRevisions): Uses formattedRevisions. Deleted the unused code for commitTime.

* public/v2/index.html: Added the search pane and the search button. Also removed the unused attribute binding
for showingDetails since this property is no longer used.

* public/v2/manifest.js:
(App.Manifest.repositories): Added.
(App.Manifest.repositoriesWithReportedCommits): Ditto. Used by App.PaneController.actions.toggleSearch to find
the default repository to search.
(App.Manifest._fetchedManifest): Populates repositories and repositoriesWithReportedCommits.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@174711 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/public/api/commits.php
Websites/perf.webkit.org/public/include/db.php
Websites/perf.webkit.org/public/v2/app.css
Websites/perf.webkit.org/public/v2/app.js
Websites/perf.webkit.org/public/v2/chart-pane.css
Websites/perf.webkit.org/public/v2/data.js
Websites/perf.webkit.org/public/v2/index.html
Websites/perf.webkit.org/public/v2/manifest.js

index 9579ece..17047d7 100644 (file)
@@ -1,5 +1,65 @@
 2014-10-13  Ryosuke Niwa  <rniwa@webkit.org>
 
+        New perf dashboard should have an ability to search commits by a keyword
+        https://bugs.webkit.org/show_bug.cgi?id=137675
+
+        Reviewed by Geoffrey Garen.
+
+        /api/commits/ now accepts query parameters to search a commit by a keyword. Its output format changed to
+        include "authorEmail" and "authorName" directly as columns instead of including an "author" object.
+        This API change allows fetch_commits_between to generate results without processing Postgres query results.
+
+        In the front end side, we've added a search pane in pane controller, and the interactive chart component
+        now has a concept of highlighted items which is used to indicate commits found by the search pane.
+
+        * public/api/commits.php:
+        (main): Extract query parameters: keyword, from, and to and use that to fetch appropriate commits.
+        (fetch_commits_between): Moved some code from main. Now takes a search term as the third argument.
+        We look for a commit if its author name or email contains the keyword or if its revision matches the keyword.
+        (format_commit): Renamed from format_commits. Now only formats one commit.
+
+        * public/include/db.php:
+        (Database::query_and_fetch_all): Now returns array() when the query results is empty (instead of false).
+
+        * public/v2/app.css: Renamed .close-button to .icon-button since it's used by a search button as well.
+
+        * public/v2/app.js:
+        (App.Pane.searchCommit): Added. Finds the commits by a search term and assigns 'highlightedItems',
+        which is a hash table that contains highlighted items' measurements' ids as keys.
+        (App.PaneController.actions.toggleSearch): Toggles the visibility of the search pane. Also sets
+        the default commit repository.
+        (App.PaneController.actions.searchCommit): Delegates the work to App.Pane.searchCommit.
+        (App.InteractiveChartComponent._constructGraphIfPossible): Fixed a bug that we weren't removing old this._dots.
+        Added the code to initialize this._highlights.
+        (App.InteractiveChartComponent._updateDimensionsIfNeeded): Updates dimensions of highlight lines.
+        (App.InteractiveChartComponent._updateHighlightPositions): Added. Ditto.
+        (App.InteractiveChartComponent._highlightedItemsChanged): Adds vertical lines for highlighted items and deletes
+        the existing lines for the old highlighted items.
+        (App.CommitsViewerComponent.commitsChanged): Updated the code per JSON API change mentioned above.
+        Also fixed a bug that the code tries to update the commits viewer even if the viewer had already been destroyed. 
+
+        * public/v2/chart-pane.css: Added style for the search pane and the search button.
+
+        * public/v2/data.js: Turned FetchCommitsForTimeRange into a class: CommitLogs.
+        (CommitLogs): Added.
+        (CommitLogs.fetchForTimeRange): Renamed from FetchCommitsForTimeRange. Takes a search term as an argument.
+        (CommitLogs._cachedCommitsBetween): Extracted from FetchCommitsForTimeRange.
+        (CommitLogs._cacheConsecutiveCommits): Ditto.
+        (FetchCommitsForTimeRange._cachedCommitsByRepository): Deleted.
+        (Measurement.prototype.commitTimeForRepository): Extracted from formattedRevisions.
+        (Measurement.prototype.formattedRevisions): Uses formattedRevisions. Deleted the unused code for commitTime.
+
+        * public/v2/index.html: Added the search pane and the search button. Also removed the unused attribute binding
+        for showingDetails since this property is no longer used.
+
+        * public/v2/manifest.js:
+        (App.Manifest.repositories): Added.
+        (App.Manifest.repositoriesWithReportedCommits): Ditto. Used by App.PaneController.actions.toggleSearch to find
+        the default repository to search.
+        (App.Manifest._fetchedManifest): Populates repositories and repositoriesWithReportedCommits.
+
+2014-10-13  Ryosuke Niwa  <rniwa@webkit.org>
+
         Unreviewed build fix after r174555.
 
         * public/include/manifest.php:
index 83672af..7679cd2 100644 (file)
@@ -20,7 +20,10 @@ function main($paths) {
     $single_commit = NULL;
     $commits = array();
     if (!$filter) {
-        $commits = $db->fetch_table('commits', 'commit_time');
+        $keyword = array_get($_GET, 'keyword');
+        $from = array_get($_GET, 'from');
+        $to = array_get($_GET, 'to');
+        $commits = fetch_commits_between($db, $repository_id, $from, $to, $keyword);
     } else if ($filter == 'oldest') {
         $single_commit = $db->select_first_row('commits', 'commit', array('repository' => $repository_id), 'time');
     } else if ($filter == 'latest') {
@@ -28,20 +31,16 @@ function main($paths) {
     } else if ($filter == 'last-reported') {
         $single_commit = $db->select_last_row('commits', 'commit', array('repository' => $repository_id, 'reported' => true), 'time');
     } else if (ctype_alnum($filter)) {
-        $single_commit = commit_from_revision($db, $repository_id, $repository_name, $filter);
+        $single_commit = commit_from_revision($db, $repository_id, $filter);
     } else {
         $matches = array();
         if (!preg_match('/([A-Za-z0-9]+)[\:\-]([A-Za-z0-9]+)/', $filter, $matches))
             exit_with_error('UnknownFilter', array('repositoryName' => $repository_name, 'filter' => $filter));
 
-        $first = commit_from_revision($db, $repository_id, $matches[1])['commit_time'];
-        $second = commit_from_revision($db, $repository_id, $matches[2])['commit_time'];
-        $in_order = $first < $second;
-
-        $commits = fetch_commits_between($db, $repository_id, $in_order ? $first : $second, $in_order ? $second : $first);
+        $commits = fetch_commits_between($db, $repository_id, $matches[1], $matches[2]);
     }
 
-    exit_with_success(array('commits' => format_commits($single_commit ? array($single_commit) : $commits)));
+    exit_with_success(array('commits' => $single_commit ? format_commit($single_commit) : $commits));
 }
 
 function commit_from_revision($db, $repository_id, $revision) {
@@ -55,28 +54,51 @@ function commit_from_revision($db, $repository_id, $revision) {
     return $row;
 }
 
-function fetch_commits_between($db, $repository_id, $from, $to) {
-    $commits = $db->query_and_fetch_all('SELECT * FROM commits
-        WHERE commit_repository = $1 AND commit_time >= $2 AND commit_time <= $3 AND commit_reported = true ORDER BY commit_time',
-        array($repository_id, $from, $to));
-    if (!$commits)
-        exit_with_error('FailedToFetchCommits', array('repository' => $repository_id, 'from' => $from, 'to' => $to));
+function fetch_commits_between($db, $repository_id, $first, $second, $keyword = NULL) {
+    $statements = 'SELECT commit_id as "id",
+        commit_revision as "revision",
+        commit_parent as "parent",
+        commit_time as "time",
+        commit_author_name as "authorName",
+        commit_author_email as "authorEmail",
+        commit_message as "message"
+        FROM commits WHERE commit_repository = $1 AND commit_reported = true';
+    $values = array($repository_id);
+
+    if ($first && $second) {
+        $first = commit_from_revision($db, $repository_id, $first)['commit_time'];
+        $second = commit_from_revision($db, $repository_id, $second)['commit_time'];
+        $in_order = $first < $second;
+        array_push($values, $in_order ? $first : $second);
+        $statements .= ' AND commit_time >= $' . count($values);
+        array_push($values, $in_order ? $second : $first);
+        $statements .= ' AND commit_time <= $' . count($values);
+    }
+
+    if ($keyword) {
+        array_push($values, '%' . str_replace(array('\\', '_', '@'), array('\\\\', '\\_', '\\%'), $keyword) . '%');
+        $index = '$' . count($values);
+        $statements .= " AND (commit_author_name LIKE $index OR commit_author_email LIKE $index";
+        array_push($values, ltrim($keyword, 'r'));
+        $statements .= ' OR commit_revision = $' . count($values) . ')';
+    }
+
+    $commits = $db->query_and_fetch_all($statements . ' ORDER BY commit_time', $values);
+    if (!is_array($commits))
+        exit_with_error('FailedToFetchCommits', array('repository' => $repository_id, 'first' => $first, 'second' => $second));
     return $commits;
 }
 
-function format_commits($commits) {
-    $formatted_commits = array();
-    foreach ($commits as $commit_row) {
-        array_push($formatted_commits, array(
-            'id' => $commit_row['commit_id'],
-            'revision' => $commit_row['commit_revision'],
-            'parent' => $commit_row['commit_parent'],
-            'time' => $commit_row['commit_time'],
-            'author' => array('name' => $commit_row['commit_author_name'], 'email' => $commit_row['commit_author_email']),
-            'message' => $commit_row['commit_message']
-        ));
-    }
-    return $formatted_commits;
+function format_commit($commit_row) {
+    return array(array(
+        'id' => $commit_row['commit_id'],
+        'revision' => $commit_row['commit_revision'],
+        'parent' => $commit_row['commit_parent'],
+        'time' => $commit_row['commit_time'],
+        'authorName' => $commit_row['commit_author_name'],
+        'authorEmail' => $commit_row['commit_author_email'],
+        'message' => $commit_row['commit_message']
+    ));
 }
 
 main(array_key_exists('PATH_INFO', $_SERVER) ? explode('/', trim($_SERVER['PATH_INFO'], '/')) : array());
index ed56506..40c90ef 100644 (file)
@@ -185,10 +185,12 @@ class Database
 
     function query_and_fetch_all($query, $params = array()) {
         if (!$this->connection)
-            return false;
+            return NULL;
         $result = pg_query_params($this->connection, $query, $params);
         if (!$result)
-            return false;
+            return NULL;
+        if (pg_num_rows($result) == 0)
+            return array();
         return pg_fetch_all($result);
     }
 
index b19ccb5..a9938e0 100755 (executable)
@@ -115,14 +115,14 @@ body {
 }
 
 
-.close-button {
+.icon-button {
     width: 1rem;
     height: 1rem;
 }
-.close-button g {
+.icon-button g {
     stroke: #ccc;
 }
-.close-button:hover g {
+.icon-button:hover g {
     stroke: #666;
 }
 
index f48ed4c..c34cd56 100755 (executable)
@@ -287,9 +287,36 @@ App.Pane = Ember.Object.extend({
     metricId: null,
     metric: null,
     selectedItem: null,
-    init: function ()
-    {
-        this._super();
+    searchCommit: function (repository, keyword) {
+        var self = this;
+        var repositoryName = repository.get('id');
+        CommitLogs.fetchForTimeRange(repositoryName, null, null, keyword).then(function (commits) {
+            if (self.isDestroyed || !self.get('chartData') || !commits.length)
+                return;
+            var currentRuns = self.get('chartData').current.timeSeriesByCommitTime().series();
+            if (!currentRuns.length)
+                return;
+
+            var highlightedItems = {};
+            var commitIndex = 0;
+            for (var runIndex = 0; runIndex < currentRuns.length && commitIndex < commits.length; runIndex++) {
+                var measurement = currentRuns[runIndex].measurement;
+                var commitTime = measurement.commitTimeForRepository(repositoryName);
+                if (!commitTime)
+                    continue;
+                if (commits[commitIndex].time <= commitTime) {
+                    highlightedItems[measurement.id()] = true;
+                    do {
+                        commitIndex++;
+                    } while (commitIndex < commits.length && commits[commitIndex].time <= commitTime);
+                }
+            }
+
+            self.set('highlightedItems', highlightedItems);
+        }, function () {
+            // FIXME: Report errors
+            this.set('highlightedItems', {});
+        });
     },
     _fetch: function () {
         var platformId = this.get('platformId');
@@ -646,6 +673,19 @@ App.PaneController = Ember.ObjectController.extend({
         {
             this.parentController.removePane(this.get('model'));
         },
+        toggleSearch: function ()
+        {
+            if (!App.Manifest.repositoriesWithReportedCommits)
+                return;
+            var model = this.get('model');
+            if (!model.get('commitSearchRepository'))
+                model.set('commitSearchRepository', App.Manifest.repositoriesWithReportedCommits[0]);
+            this.toggleProperty('showingSearchPane');
+        },
+        searchCommit: function () {
+            var model = this.get('model');
+            model.searchCommit(model.get('commitSearchRepository'), model.get('commitSearchKeyword'));                
+        },
         zoomed: function (selection)
         {
             this.set('mainPlotDomain', selection ? selection : this.get('overviewDomain'));
@@ -843,7 +883,12 @@ App.InteractiveChartComponent = Ember.Component.extend({
         if (this._areas)
             this._areas.forEach(function (area) { area.remove(); });
         this._areas = [];
+        if (this._dots)
+            this._dots.forEach(function (dot) { dots.remove(); });
         this._dots = [];
+        if (this._highlights)
+            this._highlights.forEach(function (highlight) { _highlights.remove(); });
+        this._highlights = [];
 
         this._currentTimeSeries = chartData.current.timeSeriesByCommitTime();
         this._currentTimeSeriesData = this._currentTimeSeries.series();
@@ -1018,6 +1063,7 @@ App.InteractiveChartComponent = Ember.Component.extend({
                 .attr("cx", function(measurement) { return xScale(measurement.time); })
                 .attr("cy", function(measurement) { return yScale(measurement.value); });
         });
+        this._updateHighlightPositions();
 
         if (this._brush) {
             if (selection)
@@ -1045,6 +1091,19 @@ App.InteractiveChartComponent = Ember.Component.extend({
             .style("z-index", "100")
             .text(this._yAxisUnit);
     },
+    _updateHighlightPositions: function () {
+        var xScale = this._x;
+        var yScale = this._y;
+        var y2 = this._margin.top + this._contentHeight;
+        this._highlights.forEach(function (highlight) {
+            highlight
+                .attr("y1", 0)
+                .attr("y2", y2)
+                .attr("y", function(measurement) { return yScale(measurement.value); })
+                .attr("x1", function(measurement) { return xScale(measurement.time); })
+                .attr("x2", function(measurement) { return xScale(measurement.time); });
+        });
+    },
     _computeXAxisDomain: function (timeSeries)
     {
         var extent = d3.extent(timeSeries, function(point) { return point.time; });
@@ -1317,6 +1376,26 @@ App.InteractiveChartComponent = Ember.Component.extend({
             }
         }
     }.observes('selectedItem').on('init'),
+    _highlightedItemsChanged: function () {
+        if (!this._margin)
+            return;
+
+        var highlightedItems = this.get('highlightedItems');
+
+        var data = this._currentTimeSeriesData.filter(function (item) { return highlightedItems[item.measurement.id()]; });
+
+        if (this._highlights)
+            this._highlights.forEach(function (highlight) { highlight.remove(); });
+
+        this._highlights.push(this._clippedContainer
+            .selectAll(".highlight")
+                .data(data)
+            .enter().append("line")
+                .attr("class", "highlight"));
+
+        this._updateHighlightPositions();
+
+    }.observes('highlightedItems'),
     _updateCurrentItemIndicators: function ()
     {
         if (!this._currentItemLine)
@@ -1412,18 +1491,21 @@ App.CommitsViewerComponent = Ember.Component.extend({
             return;
 
         var self = this;
-        FetchCommitsForTimeRange(repository, from, to).then(function (commits) {
+        CommitLogs.fetchForTimeRange(repository.get('id'), from, to).then(function (commits) {
+            if (self.isDestroyed)
+                return;
             self.set('commits', commits.map(function (commit) {
                 return Ember.Object.create({
                     repository: repository,
                     revision: commit.revision,
                     url: repository.urlForRevision(commit.revision),
-                    author: commit.author.name || commit.author.email,
+                    author: commit.authorName || commit.authorEmail,
                     message: commit.message ? commit.message.substr(0, 75) : null,
                 });
             }));
         }, function () {
-            self.set('commits', []);
+            if (!self.isDestroyed)
+                self.set('commits', []);
         })
     }.observes('repository').observes('revisionInfo').on('init'),
 });
index e925a31..39f0e59 100755 (executable)
@@ -5,6 +5,7 @@
     padding: 0;
     margin-bottom: 1rem;
     outline: none;
+    position: relative;
 }
 .chart-pane header {
     background: #fff;
     top: 0.55rem;
 }
 
+.chart-pane a.search-button {
+    display: inline-block;
+    position: absolute;
+    right: 0.55rem;
+    top: 0.55rem;
+}
+
+.search-pane {
+    position: absolute;
+    right: 0rem;
+    top: 1.7rem;
+    border: 1px solid #bbb;
+    padding: 0;
+    border-radius: 0.5rem;
+    display: table;
+    background: white;
+}
+
+.search-pane.hidden {
+    display: none;
+}
+
+.search-pane input {
+    display: table-cell;
+    vertical-align: middle;
+    outline: none;
+    border: none;
+    border-top-right-radius: 0.5rem;
+    border-bottom-right-radius: 0.5rem;
+    padding: 0.5rem;
+    font-size: 1rem;
+    margin: 0;
+}
+
+.search-pane .repositories {
+    display: table-cell;
+    vertical-align: middle;
+    padding: 0 0.5rem;
+}
+
+.search-pane input:focus {
+    background-color: rgb(249, 242, 228);
+}
+
 .chart-pane .body {
     position: relative;
     width: 100%;
     fill: #f93;
 }
 
+.chart .highlight {
+    stroke: #39f;
+    stroke-dasharray: 4, 4;
+    stroke-width: 1px;
+    fill: none;
+}
+
 .chart .extent {
     stroke: #9c6;
     stroke-width: 1px;
index 32d52f2..b95dc64 100755 (executable)
@@ -1,22 +1,30 @@
 // We don't use DS.Model for these object types because we can't afford to process millions of them.
 
-function FetchCommitsForTimeRange(repository, from, to)
-{
-    var url = '../api/commits/' + repository.get('id') + '/' + from + '-' + to;
+var CommitLogs = {
+    _cachedCommitsByRepository: {}
+};
 
-    var cachedCommits = FetchCommitsForTimeRange._cachedCommitsByRepository[repository];
-    if (!cachedCommits) {
-        cachedCommits = {commitsByRevision: {}, commitsByTime: []};
-        FetchCommitsForTimeRange._cachedCommitsByRepository[repository] = cachedCommits;
+CommitLogs.fetchForTimeRange = function (repository, from, to, keyword)
+{
+    var params = [];
+    if (from && to) {
+        params.push(['from', from]);
+        params.push(['to', to]);
     }
+    if (keyword)
+        params.push(['keyword', keyword]);
 
-    if (cachedCommits) {
-        var startCommit = cachedCommits.commitsByRevision[from];
-        var endCommit = cachedCommits.commitsByRevision[to];
-        if (startCommit && endCommit) {
-            return new Ember.RSVP.Promise(function (resolve) {
-                resolve(cachedCommits.commitsByTime.slice(startCommit.index, endCommit.index + 1)) });
-        }
+    // FIXME: We should be able to use the cache if all commits in the range have been cached.
+    var useCache = from && to && !keyword;
+
+    var url = '../api/commits/' + repository + '/?' + params.map(function (keyValue) {
+        return encodeURIComponent(keyValue[0]) + '=' + encodeURIComponent(keyValue[1]);
+    }).join('&');
+
+    if (useCache) {
+        var cachedCommitsForRange = CommitLogs._cachedCommitsBetween(repository, from, to);
+        if (cachedCommitsForRange)
+            return new Ember.RSVP.Promise(function (resolve) { resolve(cachedCommitsForRange); });
     }
 
     console.log('Fecthing ' + url);
@@ -28,25 +36,52 @@ function FetchCommitsForTimeRange(repository, from, to)
                 return;
             }
 
-            data.commits.forEach(function (commit) {
-                if (cachedCommits.commitsByRevision[commit.revision])
-                    return;
-                commit.time = new Date(commit.time.replace(' ', 'T'));
-                cachedCommits.commitsByRevision[commit.revision] = commit;
-                cachedCommits.commitsByTime.push(commit);
-            });
+            var fetchedCommits = data.commits;
+            fetchedCommits.forEach(function (commit) { commit.time = new Date(commit.time.replace(' ', 'T')); });
 
-            cachedCommits.commitsByTime.sort(function (a, b) { return a.time - b.time; });
-            cachedCommits.commitsByTime.forEach(function (commit, index) { commit.index = index; });
+            if (useCache)
+                CommitLogs._cacheConsecutiveCommits(repository, from, to, fetchedCommits);
 
-            resolve(data.commits);
+            resolve(fetchedCommits);
         }).fail(function (xhr, status, error) {
             reject(xhr.status + (error ? ', ' + error : ''));
         })
     });
 }
 
-FetchCommitsForTimeRange._cachedCommitsByRepository = {};
+CommitLogs._cachedCommitsBetween = function (repository, from, to)
+{
+    var cachedCommits = this._cachedCommitsByRepository[repository];
+    if (!cachedCommits)
+        return null;
+
+    var startCommit = cachedCommits.commitsByRevision[from];
+    var endCommit = cachedCommits.commitsByRevision[to];
+    if (!startCommit || !endCommit)
+        return null;
+
+    return cachedCommits.commitsByTime.slice(startCommit.cacheIndex, endCommit.cacheIndex + 1);
+}
+
+CommitLogs._cacheConsecutiveCommits = function (repository, from, to, consecutiveCommits)
+{
+    var cachedCommits = this._cachedCommitsByRepository[repository];
+    if (!cachedCommits) {
+        cachedCommits = {commitsByRevision: {}, commitsByTime: []};
+        this._cachedCommitsByRepository[repository] = cachedCommits;
+    }
+
+    consecutiveCommits.forEach(function (commit) {
+        if (cachedCommits.commitsByRevision[commit.revision])
+            return;
+        cachedCommits.commitsByRevision[commit.revision] = commit;
+        cachedCommits.commitsByTime.push(commit);
+    });
+
+    cachedCommits.commitsByTime.sort(function (a, b) { return a.time - b.time; });
+    cachedCommits.commitsByTime.forEach(function (commit, index) { commit.cacheIndex = index; });
+}
+
 
 function Measurement(rawData)
 {
@@ -70,6 +105,15 @@ function Measurement(rawData)
     this._formattedRevisions = undefined;
 }
 
+Measurement.prototype.commitTimeForRepository = function (repositoryName)
+{
+    var revisions = this._raw['revisions'];
+    var rawData = revisions[repositoryName];
+    if (!rawData)
+        return null;
+    return new Date(rawData[1]);
+}
+
 Measurement.prototype.formattedRevisions = function (previousMeasurement)
 {
     var revisions = this._raw['revisions'];
@@ -77,13 +121,8 @@ Measurement.prototype.formattedRevisions = function (previousMeasurement)
     var formattedRevisions = {};
     for (var repositoryName in revisions) {
         var currentRevision = revisions[repositoryName][0];
-        var commitTimeInPOSIX = revisions[repositoryName][1];
-
         var previousRevision = previousRevisions ? previousRevisions[repositoryName][0] : null;
-
         var formatttedRevision = this._formatRevisionRange(previousRevision, currentRevision);
-        if (commitTimeInPOSIX)
-            formatttedRevision['commitTime'] = new Date(commitTimeInPOSIX);
         formattedRevisions[repositoryName] = formatttedRevision;
     }
 
index 18bf9e4..b1c14e1 100755 (executable)
                     {{metric.label}}
                     - {{ platform.name}}</h2>
                     <a href="#" title="Close" class="close-button" {{action "close"}}>{{partial "close-button"}}</a>
+                    {{if App.Manifest.repositoriesWithReportedCommits}}
+                        <a href="#" title="Search" class="search-button" {{action "toggleSearch"}}>{{partial "search-button"}}</a>
+                    {{/if}}
                 </header>
 
-                <div {{bind-attr class=":body showingDetails"}}>
+                <div class="body">
                     <div class="svg-container">
                     {{#if chartData}}
                         {{interactive-chart
                             currentItem=currentItem
                             currentTime=sharedTime
                             selectedItem=selectedItem
+                            highlightedItems=highlightedItems
                             selection=timeRange
                             sharedSelection=sharedSelection
                             selectionChanged="rangeChanged"
                         {{/if}}
                     </div>
                 </div>
+
+                <form {{bind-attr class=":search-pane showingSearchPane::hidden"}}>
+                    <span class="repositories">
+                        {{view Ember.Select content=App.Manifest.repositoriesWithReportedCommits
+                            optionLabelPath='content.id'
+                            selection=commitSearchRepository}}
+                    </span>
+                    {{input action="searchCommit" placeholder="Name or email" value=commitSearchKeyword}}
+                </form>
+
             </section>
         {{/each}}
     </script>
     </script>
 
     <script type="text/x-handlebars" data-template-name="close-button">
-        <svg class="close-button" viewBox="0 0 100 100">
+        <svg class="close-button icon-button" viewBox="0 0 100 100">
             <g stroke="black" stroke-width="10">
                 <circle cx="50" cy="50" r="45" fill="transparent"/>
                 <polygon points="30,30 70,70" />
         </svg>
     </script>
 
+    <script type="text/x-handlebars" data-template-name="search-button">
+        <svg class="search-button icon-button" viewBox="0 0 100 100">
+            <g stroke="black" stroke-width="15">
+                <circle cx="60" cy="40" r="30" fill="transparent"/>
+                <line x1="10" y1="90" x2="40" y2="60"/>
+            </g>
+        </svg>
+    </script>
+
     <script type="text/x-handlebars" data-template-name="spinner">
         <svg class="spinner" viewBox="0 0 100 100">
             <line x1="10" y1="50" x2="30" y2="50" stroke="black" stroke-width="10" stroke-linecap="round"/>
index b10c0be..87284b0 100755 (executable)
@@ -147,6 +147,8 @@ App.Manifest = Ember.Controller.extend({
     _platformById: {},
     _metricById: {},
     _builderById: {},
+    repositories: null,
+    repositoriesWithReportedCommits: null,
     _repositoryById: {},
     _fetchPromise: null,
     fetch: function ()
@@ -190,8 +192,12 @@ App.Manifest = Ember.Controller.extend({
             self._builderById[builder.get('id')] = builder;
         });
 
-        store.all('repository').forEach(function (repository) {
+        var repositories = store.all('repository');
+        repositories.forEach(function (repository) {
             self._repositoryById[repository.get('id')] = repository;
         });
+        this.set('repositories', repositories);
+        this.set('repositoriesWithReportedCommits',
+            repositories.filter(function (repository) { return repository.get('hasReportedCommits'); }));
     }
 }).create();