-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the versionedAt
property to the published repository info
#90
Add the versionedAt
property to the published repository info
#90
Conversation
The `versionedAt` property represents a date which is updated whenever something gets published inside a specific repository. It is a compliment to the `version` property, which is a hash representation of the same thing. Another difference is that the `versionedAt` property is included inside the repository catalog info as well.
server/shared/publishing/helpers.js
Outdated
if (spine.version) delete spine.version; | ||
spine.version = hash(spine, { algorithm: 'sha1' }); | ||
const spineData = Buffer.from(JSON.stringify(spine), 'utf8'); | ||
const hashProperties = pick(spine, without(keys(spine), ['version', 'versionedAt'])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a repo level publishedAt
let's keep things consistent and please rename this prop to publishedAt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, I realize what you're saying, but now I think it's a little bit weird to have publishedAt
property on both the repository and on the activities, but they don't mean the same thing. Is that ok with you? Or should we distinguish them somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you say that they don't mean the same thing, what exactly are you aiming at? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, publishedAt
on a repository represents a date whenever something in it, ie. its children, are published. While publishedAt
on an activity represents a date when that specific activity got published, and it doesn't get updated when one of its children gets published as well.
This is why it's possible to get an activity in the structure
array with a publishedAt
date set to null
. For example, by only publishing a child of some activity and not publishing that activity itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I can see whats confusing. When you publish activity you are also implicitly publishing repository because when activity content changed, repository content also changed. Publishing activity publishes content and meta related to that outline / structural node (not other outline activities / structural nodes) therefore the same relationship does not apply. Outline activities should be looked at in 'graph manner' which for you has hierarchical nature but in essence, does not need to be.
server/shared/publishing/helpers.js
Outdated
@@ -29,16 +31,22 @@ function publishActivity(activity) { | |||
addToSpine(spine, activity); | |||
return publishContent(repository, activity).then(content => { | |||
attachContentSummary(find(spine.structure, { id: activity.id }), content); | |||
return saveSpine(spine).then(() => activity.save()); | |||
return saveSpine(spine).then(savedSpine => { | |||
return Promise.all([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do this sequentially (make sure that file is published before marking it as published within our DB) 🔬
server/shared/publishing/helpers.js
Outdated
return saveSpine(spine).then(() => activity.save()); | ||
return saveSpine(spine).then(savedSpine => { | ||
return Promise.all([ | ||
updateRepositoryCatalog(repository, savedSpine), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have to do the same thing for unpublishing 😉
server/shared/publishing/helpers.js
Outdated
}); | ||
}); | ||
} | ||
|
||
function updateRepositoryCatalog(repository) { | ||
function updateRepositoryCatalog(repository, spine) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we only need one spine prop (at least for now) lets keep args minimal and pass publishedAt
PR updated with suggested changes! |
The
versionedAt
property represents a date which is updated wheneversomething gets published inside a specific repository. It is a
compliment to the
version
property, which is a hash representation ofthe same thing.
Another difference is that the
versionedAt
property is included insidethe repository catalog info as well.