Skip to content

Edit all data doc backend - #48433

Merged
TurnerRiley merged 20 commits into
stagingfrom
edit-all-data-doc-backend
Oct 7, 2022
Merged

Edit all data doc backend#48433
TurnerRiley merged 20 commits into
stagingfrom
edit-all-data-doc-backend

Conversation

@TurnerRiley

@TurnerRiley TurnerRiley commented Oct 3, 2022

Copy link
Copy Markdown
Contributor

This is the backend part of this Jira ticket for adding an editing interface for the list of all Data Docs, allowing an editor to add a new Data Doc, edit an existing Data Doc, or delete an existing Data Doc.

To see where the edit_all table will be:

Links

Jira ticket: here
Spec: requirement #3 here

Testing story

Local testing to ensure the addition of these files does not disrupt the current DataDoc creation and viewing behavior. Backend tests were also added for these changes.

Follow-up work

Adding the edit_all page frontend

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@TurnerRiley TurnerRiley mentioned this pull request Oct 4, 2022
8 tasks
@TurnerRiley
TurnerRiley requested a review from a team October 5, 2022 17:12
Comment thread dashboard/app/controllers/data_docs_controller.rb
Comment thread dashboard/config/routes.rb Outdated
Comment thread dashboard/test/controllers/data_docs_controller_test.rb
Comment thread dashboard/test/controllers/data_docs_controller_test.rb
Comment thread dashboard/test/controllers/data_docs_controller_test.rb
Comment thread dashboard/test/controllers/data_docs_controller_test.rb Outdated
@megcrenshaw

Copy link
Copy Markdown

This is looking great! 🥳 Left some small comments inline

@davidsbailey davidsbailey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I got part way through reviewing, and was hoping to poke around at it. but the page does not appear to be loading any contents. I just created at least one data doc via /data_docs/new. am I on the right url?
Screen Shot 2022-10-06 at 12 45 16 PM

Comment thread dashboard/app/controllers/data_docs_controller.rb Outdated
@TurnerRiley

TurnerRiley commented Oct 6, 2022

Copy link
Copy Markdown
Contributor Author

I got part way through reviewing, and was hoping to poke around at it. but the page does not appear to be loading any contents. I just created at least one data doc via /data_docs/new. am I on the right url? Screen Shot 2022-10-06 at 12 45 16 PM

Oh for now that's all it's meant to show! The frontend will be in a separate PR, I'm just doing what I did with the edit data doc PR where there's just some text saying this is the right page. I could add a list element like the index page to temporarily show all created docs until the frontend PR is merged if that sounds good?

@davidsbailey

Copy link
Copy Markdown
Member

Oh for now that's all it's meant to show! The frontend will be in a separate PR, I'm just doing what I did with the edit data doc PR where there's just some text saying this is the right page. I could add a list element like the index page to temporarily show all created docs until the frontend PR is merged if that sounds good?

Oh I see - it does say it is the backend PR! this approach seems fine for now, maybe we can discuss the merits of this approach in standup sometime.

@davidsbailey davidsbailey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good, nice tests!

@data_doc.destroy!
render(status: :ok, plain: "Destroyed #{@data_doc.key}")
rescue
render(status: :not_acceptable, plain: @data_doc.errors)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is what I wanted to experiment with -- what happens if I try to delete a doc that does not exist? I'm not 100% sure we'll hit this codepath, or if we'll have already rendered here:

return render :not_found unless @data_doc

I like the idea of rescuing known errors and returning a helpful message to the user, but only in cases we anticipate and where we know it was the client's fault. if there is another kind of error, it is important for us to return a 5xx, which is the default when an exception is not rescued. this will make sure it shows up as an error in HoneyBadger.

For now I'd say this looks good to merge, but let's revisit this as soon as we have a frontend to try deleting things (including things which do not exist).

@TurnerRiley TurnerRiley Oct 6, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thank you for the feedback! I think you're right that line 65 will never be reached, so I think I'll fix it now for consistency with this being the backend PR!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(deleted my last comment because it was in the wrong place)
Good call re :not_found here! I like that approach (not rescuing errors in the destroy method)

Comment thread dashboard/config/routes.rb Outdated
assert_raise ActiveRecord::RecordNotFound do
data_doc_to_delete.reload
end
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

oh, I just realized that a unit test here would be a great way to test out what happens when you try to delete a nonexistent entry. I'm not sure this is super critical, so I'm also fine with you waiting until you have the frontend PR and testing that manually.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will do! I'll add it now to keep the backend changes in this PR!

@TurnerRiley

Copy link
Copy Markdown
Contributor Author

Oh for now that's all it's meant to show! The frontend will be in a separate PR, I'm just doing what I did with the edit data doc PR where there's just some text saying this is the right page. I could add a list element like the index page to temporarily show all created docs until the frontend PR is merged if that sounds good?

Oh I see - it does say it is the backend PR! this approach seems fine for now, maybe we can discuss the merits of this approach in standup sometime.

Yes that sounds good! I'd love some suggestions on how to best approach this!

@megcrenshaw

Copy link
Copy Markdown

Oh for now that's all it's meant to show! The frontend will be in a separate PR, I'm just doing what I did with the edit data doc PR where there's just some text saying this is the right page. I could add a list element like the index page to temporarily show all created docs until the frontend PR is merged if that sounds good?

Oh I see - it does say it is the backend PR! this approach seems fine for now, maybe we can discuss the merits of this approach in standup sometime.

Ditto –– I like vertical slicing and I'm not sure how to always do that in cases like these when PRs get big.

get '/s/csp9-2020/lockable/1(*all)', to: redirect(path: '/s/csp9-2020/lessons/9%{all}')
get '/s/csp10-2020/lockable/1(*all)', to: redirect(path: '/s/csp10-2020/lessons/14%{all}')

resources :data_docs, only: [:new, :create, :edit, :update, :show, :index], param: :key

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I feel like we've achieved a badge using all the routes 🥇

@TurnerRiley
TurnerRiley merged commit f0c7f60 into staging Oct 7, 2022
@TurnerRiley
TurnerRiley deleted the edit-all-data-doc-backend branch October 7, 2022 16:54
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.

3 participants