Compare commits

...

1 Commits

Author SHA1 Message Date
Jonathan Gramain 93b7c4fe14 bugfix: MD-712 special key prefix M for masters and V for versions
Work in progress
2019-12-30 15:20:31 -08:00
2 changed files with 32 additions and 9 deletions

View File

@ -3,7 +3,7 @@
const Delimiter = require('./delimiter').Delimiter; const Delimiter = require('./delimiter').Delimiter;
const Version = require('../../versioning/Version').Version; const Version = require('../../versioning/Version').Version;
const VSConst = require('../../versioning/constants').VersioningConstants; const VSConst = require('../../versioning/constants').VersioningConstants;
const { FILTER_ACCEPT, FILTER_SKIP, SKIP_NONE } = require('./tools'); const { inc, FILTER_ACCEPT, FILTER_SKIP, SKIP_NONE } = require('./tools');
const VID_SEP = VSConst.VersionId.Separator; const VID_SEP = VSConst.VersionId.Separator;
@ -31,6 +31,26 @@ class DelimiterMaster extends Delimiter {
this.prvPHDKey = undefined; this.prvPHDKey = undefined;
} }
genMDParams() {
const params = {};
if (this.prefix) {
params.gte = `M${this.prefix}`;
params.lt = `M${inc(this.prefix)}`;
} else {
params.gte = `M`;
params.lt = `N`; // stop after the last master key
}
const startVal = this[this.continueMarker] || this[this.startMarker];
if (startVal) {
if (params.gte > `M${startVal}`) {
return params;
}
delete params.gte;
params.gt = `M${startVal}`;
}
return params;
}
/** /**
* Filter to apply on each iteration, based on: * Filter to apply on each iteration, based on:
* - prefix * - prefix
@ -129,9 +149,9 @@ class DelimiterMaster extends Delimiter {
const index = this[this.nextContinueMarker]. const index = this[this.nextContinueMarker].
lastIndexOf(this.delimiter); lastIndexOf(this.delimiter);
if (index === this[this.nextContinueMarker].length - 1) { if (index === this[this.nextContinueMarker].length - 1) {
return this[this.nextContinueMarker]; return `M${this[this.nextContinueMarker]}`;
} }
return this[this.nextContinueMarker] + VID_SEP; return `M${this[this.nextContinueMarker]}${VID_SEP}`;
} }
return SKIP_NONE; return SKIP_NONE;
} }

View File

@ -9,7 +9,7 @@ const { inc, FILTER_END, FILTER_ACCEPT, FILTER_SKIP, SKIP_NONE } =
const VID_SEP = VSConst.VersionId.Separator; const VID_SEP = VSConst.VersionId.Separator;
function formatVersionKey(key, versionId) { function formatVersionKey(key, versionId) {
return `${key}${VID_SEP}${versionId}`; return `V${key}${VID_SEP}${versionId}`;
} }
/** /**
@ -41,11 +41,14 @@ class DelimiterVersions extends Delimiter {
genMDParams() { genMDParams() {
const params = {}; const params = {};
if (this.parameters.prefix) { if (this.parameters.prefix) {
params.gte = this.parameters.prefix; params.gte = `V${this.parameters.prefix}`;
params.lt = inc(this.parameters.prefix); params.lt = `V${inc(this.parameters.prefix)}`;
} else {
params.gte = `V`;
params.lt = `W`; // stop after the last version key
} }
if (this.parameters.keyMarker) { if (this.parameters.keyMarker) {
if (params.gte && params.gte > this.parameters.keyMarker) { if (params.gte > `V${this.parameters.keyMarker}`) {
return params; return params;
} }
delete params.gte; delete params.gte;
@ -55,7 +58,7 @@ class DelimiterVersions extends Delimiter {
params.gt = formatVersionKey(this.parameters.keyMarker, params.gt = formatVersionKey(this.parameters.keyMarker,
this.parameters.versionIdMarker); this.parameters.versionIdMarker);
} else { } else {
params.gt = inc(this.parameters.keyMarker + VID_SEP); params.gt = `V${inc(this.parameters.keyMarker + VID_SEP)}`;
} }
} }
return params; return params;
@ -137,7 +140,7 @@ class DelimiterVersions extends Delimiter {
if (this.NextMarker) { if (this.NextMarker) {
const index = this.NextMarker.lastIndexOf(this.delimiter); const index = this.NextMarker.lastIndexOf(this.delimiter);
if (index === this.NextMarker.length - 1) { if (index === this.NextMarker.length - 1) {
return this.NextMarker; return `V${this.NextMarker}`;
} }
} }
return SKIP_NONE; return SKIP_NONE;