Skip to content

Commit

Permalink
Bugfix: standard version being showed both stable and deprecated (#132)
Browse files Browse the repository at this point in the history
resolves standards/#446

Signed-off-by: Matthias Büchse <matthias.buechse@cloudandheat.com>
  • Loading branch information
mbuechse authored Jan 17, 2024
1 parent 906a51c commit 6b8de7f
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions populateStds.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ filenames.forEach((filename) => {
id: filename.substring(0, filename.length - 3),
adrId: components[1],
version: components[2],
status: {},
}
obj.isStable = obj.stabilized_at !== undefined && obj.stabilized_at <= today
obj.isObsolete = obj.obsoleted_at !== undefined && obj.obsoleted_at <= today
obj.isEffective = obj.isStable && !obj.isObsolete
// now calculate the properties for the columns (plus stable0 as a helper)
obj.status.draft = obj.stabilized_at === undefined
obj.status.stable0 = !obj.status.draft && obj.stabilized_at <= today
obj.status.deprecated = obj.obsoleted_at !== undefined && obj.obsoleted_at < today
obj.status.stable = !obj.status.draft && !obj.status.stable0 && !obj.status.deprecated
obj.status.effective = obj.status.stable0 && !obj.status.deprecated
var track = obj.track
if (track === undefined) return
if (tracks[track] === undefined) tracks[track] = {}
Expand Down Expand Up @@ -100,12 +104,8 @@ ${headerLegend}
tlines.push('| --------- | ------------ | ----- | ------- | --------- | ----------- |')
Object.entries(trackEntry[1]).forEach((standardEntry) => {
var versions = standardEntry[1].versions
// unfortunately, some standards are obsolete without being stable
var draftVersions = versions.filter((v) => v.stabilized_at === undefined && v.obsoleted_at === undefined)
var stableVersions = versions.filter((v) => v.stabilized_at !== undefined && !v.isEffective)
var effectiveVersions = versions.filter((v) => v.isEffective)
var deprecatedVersions = versions.filter((v) => v.isObsolete)
var ref = versions[versions.length - 1]
var effectiveVersions = versions.filter((v) => v.status.effective)
if (effectiveVersions.length) {
ref = effectiveVersions[effectiveVersions.length - 1]
}
Expand All @@ -130,7 +130,9 @@ ${headerLegend}
slines.push('| Version | Type | State | stabilized | obsoleted |')
slines.push('| -------- | ----- | ------- | ---------- | --------- |')
var link = `[scs-${adrId}](/standards/${track.toLowerCase()}/scs-${adrId})`
var versionList = `${mkLinkList(draftVersions) || '-'} | ${mkLinkList(stableVersions) || '-'} | ${mkLinkList(effectiveVersions) || '-'} | ${mkLinkList(deprecatedVersions) || '-'}`
var versionList = ['draft', 'stable', 'effective', 'deprecated'].map(
(column) => mkLinkList(versions.filter((v) => v.status[column])) || '-'
).join(' | ')
lines.push(`| ${link} | ${track} | ${ref.title} | ${versionList} |`)
tlines.push(`| ${link} | ${ref.title} | ${versionList} |`)
standardEntry[1].versions.forEach((obj) => {
Expand Down

0 comments on commit 6b8de7f

Please sign in to comment.