Instead of sending DB IDs, send "internal IDs" which are DB IDs hashed. This way, we can still calculate the ancestors without hitting the DB further, but without leaking the size of the images table
This commit is contained in:
parent
dd4037e324
commit
63628678b8
7 changed files with 59 additions and 36 deletions
|
@ -493,7 +493,7 @@ function RepoCtrl($scope, $sanitize, Restangular, ImageMetadataService, ApiServi
|
|||
};
|
||||
|
||||
$scope.findImageForTag = function(tag) {
|
||||
return tag && $scope.imageByDBID && $scope.imageByDBID[tag.dbid];
|
||||
return tag && $scope.imageByInternalId && $scope.imageByInternalId[tag.internal_id];
|
||||
};
|
||||
|
||||
$scope.createOrMoveTag = function(image, tagName, opt_invalid) {
|
||||
|
@ -681,9 +681,9 @@ function RepoCtrl($scope, $sanitize, Restangular, ImageMetadataService, ApiServi
|
|||
};
|
||||
|
||||
var forAllTagImages = function(tag, callback) {
|
||||
if (!tag || !$scope.imageByDBID) { return; }
|
||||
if (!tag || !$scope.imageByInternalId) { return; }
|
||||
|
||||
var tag_image = $scope.imageByDBID[tag.dbid];
|
||||
var tag_image = $scope.imageByInternalId[tag.internal_id];
|
||||
if (!tag_image) { return; }
|
||||
|
||||
// Callback the tag's image itself.
|
||||
|
@ -693,7 +693,7 @@ function RepoCtrl($scope, $sanitize, Restangular, ImageMetadataService, ApiServi
|
|||
if (!tag_image.ancestors) { return; }
|
||||
var ancestors = tag_image.ancestors.split('/');
|
||||
for (var i = 0; i < ancestors.length; ++i) {
|
||||
var image = $scope.imageByDBID[ancestors[i]];
|
||||
var image = $scope.imageByInternalId[ancestors[i]];
|
||||
if (image) {
|
||||
callback(image);
|
||||
}
|
||||
|
@ -782,10 +782,10 @@ function RepoCtrl($scope, $sanitize, Restangular, ImageMetadataService, ApiServi
|
|||
$scope.specificImages = [];
|
||||
|
||||
// Build various images for quick lookup of images.
|
||||
$scope.imageByDBID = {};
|
||||
$scope.imageByInternalId = {};
|
||||
for (var i = 0; i < $scope.images.length; ++i) {
|
||||
var currentImage = $scope.images[i];
|
||||
$scope.imageByDBID[currentImage.dbid] = currentImage;
|
||||
$scope.imageByInternalId[currentImage.internal_id] = currentImage;
|
||||
}
|
||||
|
||||
// Dispose of any existing tree.
|
||||
|
|
Reference in a new issue