Skip to content
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

Merged

Conversation

2Pacalypse-
Copy link
Contributor

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.

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.
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']));
Copy link
Collaborator

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

Copy link
Contributor Author

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?

Copy link
Collaborator

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? 🤔

Copy link
Contributor Author

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.

Copy link
Collaborator

@underscope underscope Apr 27, 2018

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.

@@ -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([
Copy link
Collaborator

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) 🔬

return saveSpine(spine).then(() => activity.save());
return saveSpine(spine).then(savedSpine => {
return Promise.all([
updateRepositoryCatalog(repository, savedSpine),
Copy link
Collaborator

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 😉

});
});
}

function updateRepositoryCatalog(repository) {
function updateRepositoryCatalog(repository, spine) {
Copy link
Collaborator

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 :bowtie:

@2Pacalypse-
Copy link
Contributor Author

PR updated with suggested changes!

@underscope underscope merged commit ccd22fa into ExtensionEngine:develop Apr 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants