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

Rename specialist document #837

Merged
merged 18 commits into from
Mar 14, 2017
Merged

Rename specialist document #837

merged 18 commits into from
Mar 14, 2017

Conversation

chrislo
Copy link
Contributor

@chrislo chrislo commented Mar 10, 2017

This PR replaces the use of the term "specialist document" with the term "section". The publishing of what are known as Specialist Documents was moved to a separate application some time ago. However the name still remains in this codebase and seems to be used to refer to a section of a manual. We've gone with Section as opposed to something like ManualSection as the application currently only has responsibility for manuals and their sections and this seems to match the language used in the UI.

This PR does not currently touch any data - the underlying mongodb collection for SectionEdition is still specialist_document_editions. I'd like someone to help check that this continues to work with a recent copy of a production-like database.

I think we'll rename the collection in a subsequent commit after this one has landed as we need to do some investigation about whether that would involve application downtime.

@chrislo chrislo force-pushed the rename-specialist-document branch 2 times, most recently from ec9dbc1 to d8d4ac7 Compare March 10, 2017 13:29
@chrisroos
Copy link
Contributor

This PR does not currently touch any data - the underlying mongodb collection for SectionEdition is still specialist_document_editions. I'd like someone to help check that this continues to work with a recent copy of a production-like database.

I took a recent dump of production data and checked out this branch locally. I clicked around the manuals-publisher UI and can confirm that everything appears to work as expected.

@chrislo
Copy link
Contributor Author

chrislo commented Mar 10, 2017

Thanks @chrisroos - I've rebased this against master so I think it's ready for review.

@chrislo chrislo changed the title [WIP] Rename specialist document Rename specialist document Mar 10, 2017
@chrislo chrislo requested a review from floehopper March 10, 2017 15:27
@chrisroos
Copy link
Contributor

I've added issue #848 to prompt us to rename the Mongo collection once this has been merged.

@floehopper floehopper self-assigned this Mar 13, 2017
Copy link
Contributor

@floehopper floehopper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All my comments are very minor. I'm happy for this to be merged as it stands, so I'm marking it as approved.

documents = subject.documents.to_a
expect(documents.size).to eq 2

document_1 = documents[0]
expect(document_1).to be_a ::SpecialistDocument
expect(document_1).to be_a ::Section
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why the :: prefix is needed here and elsewhere in this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it struck us as odd too - will investigate after merging.

@@ -6,7 +6,7 @@
require "builders/manual_document_builder"
require "manual_with_documents"
require "slug_generator"
require "specialist_document"
require "section"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this require statement still necessary now that the classname matches the filename?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly not - I think we'll take a look at this after we merge this PR, there's probably a few unnecessary requires scattered around.

@@ -7,7 +7,7 @@ class Attachment
field :file_id, type: String
field :file_url, type: String

embedded_in :specialist_document_edition
embedded_in :section_edition
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be useful to mention why this change does not require any database migration, i.e. can you confirm that none of the existing attachments store a reference to their parent edition using this key. I'm guessing it's because this is an embedded document...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's correct. I've addressed this comment in an improved commit message on b0b409a.

@@ -1,13 +1,12 @@
require "specialist_document_repository"
require "manual_repository"
require "specialist_document_edition"
require "section_edition"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this require statement necessary now that the class name matches the filename?

@floehopper
Copy link
Contributor

There are a bunch of classes named *ManualSection*. Given the choice to rename SpecialistDocument to Section, we will want to rename them to *Section*.

@chrisroos
Copy link
Contributor

I'm going to rebase this on master given all the recent changes.

We want to rename this class. To make it easier to do this we set the
mongo collection that the data is stored in explicitly. This means we
can change the code independently from the persistence.
@chrisroos
Copy link
Contributor

I've rebased and force pushed.

I'm going to hold off merging until I can pair with @chrislo to address @floehopper's comments and to double check that we're happy with the name Section instead of ManualSection.

Although we change the name of the collection that attachments are
embedded in (with `embedded_in :section_edition` in
`app/models/attachment.rb`) we don't need to migrate any data
here. The combination of `embedded_in` on attachments and
`embeds_many` on section editions means that a record in the
underlying mongodb section edition collection looks like:

    { _id: 'abcd1234',
      ... some other fields ...,
      attachments: [
        {_id: 'efgh5678',
         filename: 'foo.txt'
         ... some other fields ...
         }
      ]
    }

That is, the relationship is defined by embedding Attachment records
in an `attachments` array under whatever is defined as the parent
collection. This continues to work when we rename the parent
collection.
We currently have no intention to make this refactor. TODO items
belong elsewhere.
This context has no associated expectations so can be removed.
We are removing references to `specialist_document` and replacing them
with `section`. Inlining the call to `Section.new` seems more
intention-revealing than renaming the method.
This factory does not appear to be used so can be removed.
We noticed here that `manual` is stubbed to receive a `documents`
method. In practice ManualUpdateType receives a ManualWithDocuments
instance and we should probably look to rename that to
ManualWithSections and give it a `sections` method instead.
@chrislo
Copy link
Contributor Author

chrislo commented Mar 14, 2017

I've raised #867 to make sure we keep track of the suggestion to rename ManualSection to Section

@chrislo
Copy link
Contributor Author

chrislo commented Mar 14, 2017

Rebasing against master and force pushing before merging.

@chrislo chrislo merged commit 9b0ef01 into master Mar 14, 2017
@chrislo chrislo deleted the rename-specialist-document branch March 14, 2017 15:38
@chrislo chrislo modified the milestone: Legacy Apr 25, 2017
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.

None yet

3 participants