Add a threshold for considering moves of tags

Fixes #516
This commit is contained in:
Joseph Schorr 2015-09-21 16:14:37 -04:00
parent d606a42e39
commit fee72225cf

View file

@ -17,6 +17,9 @@ angular.module('quay').directive('repoTagHistory', function () {
$scope.tagHistoryData = null;
$scope.tagHistoryLeaves = {};
// A delete followed by a create of a tag within this threshold is considered a move.
var MOVE_THRESHOLD = 2;
var loadTimeline = function() {
if (!$scope.repository || !$scope.isEnabled) { return; }
@ -68,11 +71,11 @@ angular.module('quay').directive('repoTagHistory', function () {
// If the tag has an end time, it was either deleted or moved.
if (tag.end_ts) {
// If a future entry exists with a start time equal to the end time for this tag,
// If a future entry exists with a start time "equal" to the end time for this tag,
// then the action was a move, rather than a delete and a create.
var currentEntries = tagEntries[tagName];
var futureEntry = currentEntries.length > 0 ? currentEntries[currentEntries.length - 1] : {};
if (futureEntry.start_ts == tag.end_ts) {
if (tag.end_ts - futureEntry.start_ts <= MOVE_THRESHOLD) {
removeEntry(futureEntry);
addEntry(futureEntry.reversion ? 'revert': 'move', tag.end_ts,
futureEntry.docker_image_id, dockerImageId);