Don’t use repository names as id’s.
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Feb 2015 05:40:34 +0000 (05:40 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Feb 2015 05:40:34 +0000 (05:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=141226

Reviewed by Chris Dumez.

Not using repository names as their id's reduces the need to fetch the entire repositories table.
Since names of repositories are available in manifest.json, we can resolve their names in the front end.

* Websites/perf.webkit.org/public/api/runs.php:
(parse_revisions_array): No longer uses $repository_id_to_name.
(main): No longer populates $repository_id_to_name.

* Websites/perf.webkit.org/public/api/triggerables.php:
(main): Don't resolve repository names.

* Websites/perf.webkit.org/public/include/manifest.php:
(ManifestGenerator::repositories): Use repositories ids as keys in the result and include their names.
(ManifestGenerator::bug_trackers): Don't resolve repository names.

* Websites/perf.webkit.org/public/js/helper-classes.js:
(TestBuild): Renamed repositoryName to repositoryId.
(TestBuild.revision): Ditto.
(TestBuild.formattedRevisions): Ditto. Continue to use the repository name in the formatted result
since this is the text shown to human.

* Websites/perf.webkit.org/public/v2/app.js:
(App.pane.searchCommit): Renamed repositoryName to repositoryId.
(App.PaneController._updateDetails): Ditto.
(App.AnalysisTaskController.updateRoots): Ditto.

* Websites/perf.webkit.org/public/v2/data.js:
(Measurement): Ditto.
(Measurement.prototype.commitTimeForRepository): Ditto.
(Measurement.prototype.formattedRevisions): Ditto.

* Websites/perf.webkit.org/public/v2/index.html: Use the repository name and the repository id as
select element's label and value respectively.

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

Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/public/api/commits.php
Websites/perf.webkit.org/public/api/runs.php
Websites/perf.webkit.org/public/api/triggerables.php
Websites/perf.webkit.org/public/include/manifest.php
Websites/perf.webkit.org/public/js/helper-classes.js
Websites/perf.webkit.org/public/v2/app.js
Websites/perf.webkit.org/public/v2/data.js
Websites/perf.webkit.org/public/v2/index.html

index e1444c1c8252de7e91c89362d518dfc50b310983..7d58bb87b57c13a09f86f3ba526ca158d7a750f0 100644 (file)
@@ -1,3 +1,43 @@
+2015-02-03  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Don’t use repository names as id’s.
+        https://bugs.webkit.org/show_bug.cgi?id=141226
+
+        Reviewed by Chris Dumez.
+
+        Not using repository names as their id's reduces the need to fetch the entire repositories table.
+        Since names of repositories are available in manifest.json, we can resolve their names in the front end.
+
+        * Websites/perf.webkit.org/public/api/runs.php:
+        (parse_revisions_array): No longer uses $repository_id_to_name.
+        (main): No longer populates $repository_id_to_name.
+
+        * Websites/perf.webkit.org/public/api/triggerables.php:
+        (main): Don't resolve repository names.
+
+        * Websites/perf.webkit.org/public/include/manifest.php:
+        (ManifestGenerator::repositories): Use repositories ids as keys in the result and include their names.
+        (ManifestGenerator::bug_trackers): Don't resolve repository names.
+
+        * Websites/perf.webkit.org/public/js/helper-classes.js:
+        (TestBuild): Renamed repositoryName to repositoryId.
+        (TestBuild.revision): Ditto.
+        (TestBuild.formattedRevisions): Ditto. Continue to use the repository name in the formatted result
+        since this is the text shown to human.
+
+        * Websites/perf.webkit.org/public/v2/app.js:
+        (App.pane.searchCommit): Renamed repositoryName to repositoryId.
+        (App.PaneController._updateDetails): Ditto.
+        (App.AnalysisTaskController.updateRoots): Ditto.
+
+        * Websites/perf.webkit.org/public/v2/data.js:
+        (Measurement): Ditto.
+        (Measurement.prototype.commitTimeForRepository): Ditto.
+        (Measurement.prototype.formattedRevisions): Ditto.
+
+        * Websites/perf.webkit.org/public/v2/index.html: Use the repository name and the repository id as
+        select element's label and value respectively.
+
 2015-02-03  Ryosuke Niwa  <rniwa@webkit.org>
 
         Unreviewed build fix. Declare $repository_id_to_name in the global scope.
index 00b73d231a50286c0d27ed3360dfd634ca3c9f5c..d0bbe0f6c82fe8f92a6c72a5bcaa0cdb38d9c02e 100644 (file)
@@ -10,11 +10,7 @@ function main($paths) {
     if (!$db->connect())
         exit_with_error('DatabaseConnectionFailure');
 
-    $repository_name = $paths[0];
-    $repository_row = $db->select_first_row('repositories', 'repository', array('name' => $repository_name));
-    if (!$repository_row)
-        exit_with_error('RepositoryNotFound', array('repositoryName' => $repository_name));
-    $repository_id = $repository_row['repository_id'];
+    $repository_id = intval($paths[0]);
 
     $filter = array_get($paths, 1);
     $single_commit = NULL;
index 46c17788bcde896c69cfa93e6c165f961b143785..d2e8664600141ec4013c684623758305c8b8e400 100644 (file)
@@ -22,8 +22,6 @@ function fetch_runs_for_config($db, $config) {
 }
 
 function parse_revisions_array($postgres_array) {
-    global $repository_id_to_name;
-
     // e.g. {"(WebKit,131456,\"2012-10-16 14:53:00\")","(Chromium,162004,)"}
     $outer_array = json_decode('[' . trim($postgres_array, '{}') . ']');
     $revisions = array();
@@ -32,7 +30,7 @@ function parse_revisions_array($postgres_array) {
         if (!$name_and_revision[0])
             continue;
         $time = strtotime(trim($name_and_revision[2], '"')) * 1000;
-        $revisions[$repository_id_to_name[trim($name_and_revision[0], '"')]] = array(trim($name_and_revision[1], '"'), $time);
+        $revisions[trim($name_and_revision[0], '"')] = array(trim($name_and_revision[1], '"'), $time);
     }
     return $revisions;
 }
@@ -50,11 +48,7 @@ function format_run($run) {
         'builder' => $run['build_builder']);
 }
 
-$repository_id_to_name = array();
-
 function main($path) {
-    global $repository_id_to_name;
-
     if (count($path) != 1)
         exit_with_error('InvalidRequest');
 
@@ -78,11 +72,6 @@ function main($path) {
     if (!$config_rows)
         exit_with_error('ConfigurationNotFound');
 
-    if ($repository_table = $db->fetch_table('repositories')) {
-        foreach ($repository_table as $repository)
-            $repository_id_to_name[$repository['repository_id']] = $repository['repository_name'];
-    }
-
     $results = array();
     foreach ($config_rows as $config) {
         if ($runs = fetch_runs_for_config($db, $config))
index 61a717a5c1ddacd274e0b6acb366c53ff6551763..318391046df6e3fdcb7838321459de9a8220c408 100644 (file)
@@ -26,14 +26,10 @@ function main($path) {
         $id_to_triggerable[$id] = array('id' => $id, 'name' => $row['triggerable_name'], 'acceptedRepositories' => &$repositories);
     }
 
-    $repository_id_to_name = array();
-    foreach ($db->select_rows('repositories', 'repository', array(), 'name') as $row)
-        $repository_id_to_name[$row['repository_id']] = $row['repository_name'];
-
     foreach ($db->select_rows('triggerable_repositories', 'trigrepo', array()) as $row) {
         $triggerable = $id_to_triggerable[$row['trigrepo_triggerable']];
         if ($triggerable)
-            array_push($triggerable['acceptedRepositories'], $repository_id_to_name[$row['trigrepo_repository']]);
+            array_push($triggerable['acceptedRepositories'], $row['trigrepo_repository']);
     }
 
     exit_with_success(array('triggerables' => array_values($id_to_triggerable)));
index 516cf97435e47d41706b22a645464478b3cd1167..3b2cd89a9c32e05de92dcdd63e9412b8c8e480ac 100644 (file)
@@ -100,7 +100,8 @@ class ManifestGenerator {
         if (!$repositories_table)
             return $repositories;
         foreach ($repositories_table as $row) {
-            $repositories[$row['repository_name']] = array(
+            $repositories[$row['repository_id']] = array(
+                'name' => $row['repository_name'],
                 'url' => $row['repository_url'],
                 'blameUrl' => $row['repository_blame_url'],
                 'hasReportedCommits' => in_array($row['repository_id'], $repositories_with_commit));
@@ -121,18 +122,12 @@ class ManifestGenerator {
     }
 
     private function bug_trackers($repositories_table) {
-        $repository_id_to_name = array();
-        if ($repositories_table) {
-            foreach ($repositories_table as $row)
-                $repository_id_to_name[$row['repository_id']] = $row['repository_name'];
-        }
-
         $tracker_id_to_repositories = array();
         $tracker_repositories_table = $this->db->fetch_table('tracker_repositories');
         if ($tracker_repositories_table) {
             foreach ($tracker_repositories_table as $row) {
                 array_push(array_ensure_item_has_array($tracker_id_to_repositories, $row['tracrepo_tracker']),
-                    $repository_id_to_name[$row['tracrepo_repository']]);
+                    $row['tracrepo_repository']);
             }
         }
 
index 8826b1821f9ac818bb8ddb2a28211cd55bda30fd..36398afd15110c6c292f0d9de1b5b987c99518c0 100755 (executable)
@@ -51,8 +51,8 @@ function TestBuild(repositories, builders, platform, rawRun) {
     const revisions = rawRun.revisions;
     var maxTime = 0;
     var revisionCount = 0;
-    for (var repositoryName in revisions) {
-        maxTime = Math.max(maxTime, revisions[repositoryName][1]); // Revision is an pair (revision, time)
+    for (var repositoryId in revisions) {
+        maxTime = Math.max(maxTime, revisions[repositoryId][1]); // Revision is an pair (revision, time)
         revisionCount++;
     }
     if (!maxTime)
@@ -81,14 +81,14 @@ function TestBuild(repositories, builders, platform, rawRun) {
         return template ? template.replace(/\$buildNumber/g, this.buildNumber()) : null;
     }
     this.platform = function () { return platform; }
-    this.revision = function(repositoryName) { return revisions[repositoryName][0]; }
+    this.revision = function(repositoryId) { return revisions[repositoryId][0]; }
     this.formattedRevisions = function (previousBuild) {
         var result = {};
-        for (var repositoryName in repositories) {
-            if (!revisions[repositoryName])
+        for (var repositoryId in repositories) {
+            if (!revisions[repositoryId])
                 continue;
-            var previousRevision = previousBuild ? previousBuild.revision(repositoryName) : undefined;
-            var currentRevision = this.revision(repositoryName);
+            var previousRevision = previousBuild ? previousBuild.revision(repositoryId) : undefined;
+            var currentRevision = this.revision(repositoryId);
             if (previousRevision === currentRevision)
                 previousRevision = undefined;
 
@@ -119,7 +119,7 @@ function TestBuild(repositories, builders, platform, rawRun) {
             }
 
             var url;
-            var repository = repositories[repositoryName];
+            var repository = repositories[repositoryId];
             if (repository) {
                 if (previousRevision)
                     url = (repository['blameUrl'] || '').replace(/\$1/g, previousRevision).replace(/\$2/g, currentRevision);
@@ -127,7 +127,7 @@ function TestBuild(repositories, builders, platform, rawRun) {
                     url = (repository['url'] || '').replace(/\$1/g, currentRevision);
             }
 
-            result[repositoryName] = {
+            result[repository.name] = {
                 'label': labelForThisRepository,
                 'currentRevision': currentRevision,
                 'previousRevision': previousRevision,
index 74d0654eb20d091c1622ce4c293fa49fd2dfe895..2e63ad1ae24a33036e4c3ce7e1a234dc93a70ca1 100755 (executable)
@@ -276,8 +276,8 @@ App.Pane = Ember.Object.extend({
     selectedItem: null,
     searchCommit: function (repository, keyword) {
         var self = this;
-        var repositoryName = repository.get('id');
-        CommitLogs.fetchForTimeRange(repositoryName, null, null, keyword).then(function (commits) {
+        var repositoryId = repository.get('id');
+        CommitLogs.fetchForTimeRange(repositoryId, null, null, keyword).then(function (commits) {
             if (self.isDestroyed || !self.get('chartData') || !commits.length)
                 return;
             var currentRuns = self.get('chartData').current.timeSeriesByCommitTime().series();
@@ -288,7 +288,7 @@ App.Pane = Ember.Object.extend({
             var commitIndex = 0;
             for (var runIndex = 0; runIndex < currentRuns.length && commitIndex < commits.length; runIndex++) {
                 var measurement = currentRuns[runIndex].measurement;
-                var commitTime = measurement.commitTimeForRepository(repositoryName);
+                var commitTime = measurement.commitTimeForRepository(repositoryId);
                 if (!commitTime)
                     continue;
                 if (commits[commitIndex].time <= commitTime) {
@@ -727,12 +727,11 @@ App.PaneController = Ember.ObjectController.extend({
         var revisions = App.Manifest.get('repositories')
             .filter(function (repository) { return formattedRevisions[repository.get('id')]; })
             .map(function (repository) {
-            var repositoryName = repository.get('id');
-            var revision = Ember.Object.create(formattedRevisions[repositoryName]);
+            var revision = Ember.Object.create(formattedRevisions[repository.get('id')]);
             revision['url'] = revision.previousRevision
                 ? repository.urlForRevisionRange(revision.previousRevision, revision.currentRevision)
                 : repository.urlForRevision(revision.currentRevision);
-            revision['name'] = repositoryName;
+            revision['name'] = repository.get('name');
             revision['repository'] = repository;
             return revision; 
         });
@@ -888,11 +887,11 @@ App.AnalysisTaskController = Ember.Controller.extend({
         var repositoryToRevisions = {};
         analysisPoints.forEach(function (point, pointIndex) {
             var revisions = point.measurement.formattedRevisions();
-            for (var repositoryName in revisions) {
-                if (!repositoryToRevisions[repositoryName])
-                    repositoryToRevisions[repositoryName] = new Array(analysisPoints.length);
-                var revision = revisions[repositoryName];
-                repositoryToRevisions[repositoryName][pointIndex] = {
+            for (var repositoryId in revisions) {
+                if (!repositoryToRevisions[repositoryId])
+                    repositoryToRevisions[repositoryId] = new Array(analysisPoints.length);
+                var revision = revisions[repositoryId];
+                repositoryToRevisions[repositoryId][pointIndex] = {
                     label: point.label + ': ' + revision.label,
                     value: revision.currentRevision,
                 };
@@ -905,15 +904,15 @@ App.AnalysisTaskController = Ember.Controller.extend({
                 return;
 
             self.set('roots', triggerable.get('acceptedRepositories').map(function (repository) {
-                var repositoryName = repository.get('id');
-                var revisions = [{value: ' ', label: 'None'}].concat(repositoryToRevisions[repositoryName]);
+                var repositoryId = repository.get('id');
+                var revisions = [{value: ' ', label: 'None'}].concat(repositoryToRevisions[repositoryId]);
                 return Ember.Object.create({
-                    name: repositoryName,
+                    name: repository.get('name'),
                     sets: [
-                        Ember.Object.create({name: 'A[' + repositoryName + ']',
+                        Ember.Object.create({name: 'A[' + repositoryId + ']',
                             revisions: revisions,
                             selection: revisions[1]}),
-                        Ember.Object.create({name: 'B[' + repositoryName + ']',
+                        Ember.Object.create({name: 'B[' + repositoryId + ']',
                             revisions: revisions,
                             selection: revisions[revisions.length - 1]}),
                     ],
index f337c62f4b6d550ef764fa8da37eab9f9e7832af..2da2fefed69d6722d4d7d6991b81ddd81abd119c 100755 (executable)
@@ -141,8 +141,8 @@ function Measurement(rawData)
         revisions = {};
     this._raw['revisions'] = revisions;
 
-    for (var repositoryName in revisions) {
-        var commitTimeOrUndefined = revisions[repositoryName][1]; // e.g. ["162190", 1389945046000]
+    for (var repositoryId in revisions) {
+        var commitTimeOrUndefined = revisions[repositoryId][1]; // e.g. ["162190", 1389945046000]
         if (latestTime < commitTimeOrUndefined)
             latestTime = commitTimeOrUndefined;
     }
@@ -152,10 +152,10 @@ function Measurement(rawData)
     this._formattedRevisions = undefined;
 }
 
-Measurement.prototype.commitTimeForRepository = function (repositoryName)
+Measurement.prototype.commitTimeForRepository = function (repositoryId)
 {
     var revisions = this._raw['revisions'];
-    var rawData = revisions[repositoryName];
+    var rawData = revisions[repositoryId];
     if (!rawData)
         return null;
     return new Date(rawData[1]);
@@ -166,11 +166,11 @@ Measurement.prototype.formattedRevisions = function (previousMeasurement)
     var revisions = this._raw['revisions'];
     var previousRevisions = previousMeasurement ? previousMeasurement._raw['revisions'] : null;
     var formattedRevisions = {};
-    for (var repositoryName in revisions) {
-        var currentRevision = revisions[repositoryName][0];
-        var previousRevision = previousRevisions ? previousRevisions[repositoryName][0] : null;
+    for (var repositoryId in revisions) {
+        var currentRevision = revisions[repositoryId][0];
+        var previousRevision = previousRevisions ? previousRevisions[repositoryId][0] : null;
         var formatttedRevision = this._formatRevisionRange(previousRevision, currentRevision);
-        formattedRevisions[repositoryName] = formatttedRevision;
+        formattedRevisions[repositoryId] = formatttedRevision;
     }
 
     return formattedRevisions;
index 237141b3364f9f53bcda05137ceb8d096bde59d4..fe477fd0cdb7582c735c0d5a3b2a0f73eb032836 100755 (executable)
 
                 <form {{bind-attr class=":search-pane showingSearchPane::hidden"}}>
                     <span class="repositories">
-                        {{view Ember.Select content=App.Manifest.repositoriesWithReportedCommits
-                            optionLabelPath='content.id'
+                        {{view Ember.Select
+                            content=App.Manifest.repositoriesWithReportedCommits
+                            optionValuePath='content.id'
+                            optionLabelPath='content.name'
                             selection=commitSearchRepository}}
                     </span>
                     {{input action="searchCommit" placeholder="Name or email" value=commitSearchKeyword}}