Title: [179591] trunk/Websites/perf.webkit.org
Revision
179591
Author
[email protected]
Date
2015-02-03 21:40:34 -0800 (Tue, 03 Feb 2015)

Log Message

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.

Modified Paths

Diff

Modified: trunk/Websites/perf.webkit.org/ChangeLog (179590 => 179591)


--- trunk/Websites/perf.webkit.org/ChangeLog	2015-02-04 05:06:15 UTC (rev 179590)
+++ trunk/Websites/perf.webkit.org/ChangeLog	2015-02-04 05:40:34 UTC (rev 179591)
@@ -1,5 +1,45 @@
 2015-02-03  Ryosuke Niwa  <[email protected]>
 
+        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  <[email protected]>
+
         Unreviewed build fix. Declare $repository_id_to_name in the global scope.
 
         * public/api/runs.php:

Modified: trunk/Websites/perf.webkit.org/public/api/commits.php (179590 => 179591)


--- trunk/Websites/perf.webkit.org/public/api/commits.php	2015-02-04 05:06:15 UTC (rev 179590)
+++ trunk/Websites/perf.webkit.org/public/api/commits.php	2015-02-04 05:40:34 UTC (rev 179591)
@@ -10,11 +10,7 @@
     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;

Modified: trunk/Websites/perf.webkit.org/public/api/runs.php (179590 => 179591)


--- trunk/Websites/perf.webkit.org/public/api/runs.php	2015-02-04 05:06:15 UTC (rev 179590)
+++ trunk/Websites/perf.webkit.org/public/api/runs.php	2015-02-04 05:40:34 UTC (rev 179591)
@@ -22,8 +22,6 @@
 }
 
 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 @@
         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 @@
         '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 @@
     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))

Modified: trunk/Websites/perf.webkit.org/public/api/triggerables.php (179590 => 179591)


--- trunk/Websites/perf.webkit.org/public/api/triggerables.php	2015-02-04 05:06:15 UTC (rev 179590)
+++ trunk/Websites/perf.webkit.org/public/api/triggerables.php	2015-02-04 05:40:34 UTC (rev 179591)
@@ -26,14 +26,10 @@
         $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)));

Modified: trunk/Websites/perf.webkit.org/public/include/manifest.php (179590 => 179591)


--- trunk/Websites/perf.webkit.org/public/include/manifest.php	2015-02-04 05:06:15 UTC (rev 179590)
+++ trunk/Websites/perf.webkit.org/public/include/manifest.php	2015-02-04 05:40:34 UTC (rev 179591)
@@ -100,7 +100,8 @@
         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 @@
     }
 
     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']);
             }
         }
 

Modified: trunk/Websites/perf.webkit.org/public/js/helper-classes.js (179590 => 179591)


--- trunk/Websites/perf.webkit.org/public/js/helper-classes.js	2015-02-04 05:06:15 UTC (rev 179590)
+++ trunk/Websites/perf.webkit.org/public/js/helper-classes.js	2015-02-04 05:40:34 UTC (rev 179591)
@@ -51,8 +51,8 @@
     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 @@
         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 @@
             }
 
             var url;
-            var repository = repositories[repositoryName];
+            var repository = repositories[repositoryId];
             if (repository) {
                 if (previousRevision)
                     url = "" || '').replace(/\$1/g, previousRevision).replace(/\$2/g, currentRevision);
@@ -127,7 +127,7 @@
                     url = "" || '').replace(/\$1/g, currentRevision);
             }
 
-            result[repositoryName] = {
+            result[repository.name] = {
                 'label': labelForThisRepository,
                 'currentRevision': currentRevision,
                 'previousRevision': previousRevision,

Modified: trunk/Websites/perf.webkit.org/public/v2/app.js (179590 => 179591)


--- trunk/Websites/perf.webkit.org/public/v2/app.js	2015-02-04 05:06:15 UTC (rev 179590)
+++ trunk/Websites/perf.webkit.org/public/v2/app.js	2015-02-04 05:40:34 UTC (rev 179591)
@@ -276,8 +276,8 @@
     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 @@
             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 @@
         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 @@
         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 @@
                 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]}),
                     ],

Modified: trunk/Websites/perf.webkit.org/public/v2/data.js (179590 => 179591)


--- trunk/Websites/perf.webkit.org/public/v2/data.js	2015-02-04 05:06:15 UTC (rev 179590)
+++ trunk/Websites/perf.webkit.org/public/v2/data.js	2015-02-04 05:40:34 UTC (rev 179591)
@@ -141,8 +141,8 @@
         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 @@
     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 @@
     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;

Modified: trunk/Websites/perf.webkit.org/public/v2/index.html (179590 => 179591)


--- trunk/Websites/perf.webkit.org/public/v2/index.html	2015-02-04 05:06:15 UTC (rev 179590)
+++ trunk/Websites/perf.webkit.org/public/v2/index.html	2015-02-04 05:40:34 UTC (rev 179591)
@@ -188,8 +188,10 @@
 
                 <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="" placeholder="Name or email" value=commitSearchKeyword}}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to