RefugeRestrooms / refugerestrooms

REFUGE restrooms indexes and maps safe restroom locations for trans, intersex, and gender nonconforming individuals.
http://www.refugerestrooms.org
GNU Affero General Public License v3.0
894 stars 261 forks source link

Rails 5.2 #505

Closed btyy77c closed 5 years ago

btyy77c commented 6 years ago

Context

Summary of Changes

Checklist

Screenshots

Before

Command-line interface booting Rails. Shows Rails 5.1.4 and Puma 3.11.2

After

Command-line interface booting Rails. Shows Rails 5.2.1 and Puma 3.12.0

DeeDeeG commented 6 years ago

@btyy77c, Thanks very much for this pull request!

As per usual for Rails updates, we'll want to test this a bunch before merging, and give it a pretty thorough review. I'll start by just making sure I can run it in Docker without errors (which I expect will be no problem).

In any case this looks great! :tada:

Happy Hacktoberfest to you! :jack_o_lantern: :computer: :fallen_leaf: :sparkles:

DeeDeeG commented 6 years ago

As an aside: I notice some of these commits are made with a different git "name" and email set than your official GitHub name/email combo. So not all of these commits would get attributed to your GitHub account properly when we merge.

(This wouldn't make a difference if we squash and merge, since it would produce just the one commit, hopefully with your correct info on it. We tend to decide on whether to squash or not at merge time.) Edit: Whoops, I see all the commits have the same author info, so squash-and-merge won't help.

If you want to go back and fix this (or have us fix it), it should be doable.

Here's two methods: https://www.git-tower.com/learn/git/faq/change-author-name-email#chapter_using+interactive+rebase https://www.git-tower.com/learn/git/faq/change-author-name-email#chapter_using+git+filter-branch

(Edit to add: If something were to go wrong with fixing name/email in these commits, I have a backup branch I intend to leave in the same state this PR started with, at least for the time being: https://github.com/DeeDeeG/RefugeRestrooms/tree/rails52-backup)

Trying this pull request out in Docker as soon as I get Docker installed on my new Ubuntu install.

DeeDeeG commented 6 years ago

I was able to test this branch in Docker. It mostly works as intended, but I noticed a few problems.

I may have missed some things, but anyways, that's enough things to start with. Thanks again, I do think this is a good place to start from. Should be fixable. :+1:

btyy77c commented 6 years ago
  • The API page isn't working. (This seems to be a canary in the coal mine; It breaks a lot.)

When I visit production, the api is not working: (https://www.refugerestrooms.org/api or https://www.refugerestrooms.org/api.json) Is there a different route or something else I should be checking? Thanks!

DeeDeeG commented 6 years ago

The API page can be visited at [base-url]/api/docs/, e.g.: 127.0.0.1:3000/api/docs/.

Edit: Trailing forward-slash is important!

DeeDeeG commented 6 years ago

I think there is something off with our Docker setup, because none of the dummy entries from db/export.csv are loaded, even on the develop branch.

On develop: The API page does work. And if I submit a new restroom, then ask for all restrooms by date on the API page, the one I submitted shows up in response.

Screenshot of the API page, showing just one result

Edit: This is fixed with #508

btyy77c commented 6 years ago

The API page can be visited at [base-url]/api/docs/, e.g.: 127.0.0.1:3000/api/docs.

So, I'm not sure how long you've worked on this application, but do you know the history of why the /api/docs app was placed in the public folder (https://github.com/RefugeRestrooms/refugerestrooms/tree/develop/public/api/docs)? Is there a reason it couldn't be part of the rails application?

btyy77c commented 6 years ago

Sorry! I didn't mean to close the pull request. I normally use gitlab and I'm apparently terrible with GitHub.

DeeDeeG commented 6 years ago

So, I'm not sure how long you've worked on this application, but do you know the history of why the /api/docs app was placed in the public folder . . .[link]. . . ?

This was before I came in. But I guess it's sort of a hack/kludge that lets this page be viewable without doing a lot of route configuration and so on.

Is there a reason it couldn't be part of the rails application?

No, I think that is just how the contributor who added this ended up doing it. Ideally, in my opinion, we would go in and install this as a proper nodejs package via our package.json. But "part of the app" sounds like the right direction to go in :+1: .

Edit: Technical typos.

Sorry! I didn't mean to close the pull request. I normally use gitlab and I'm apparently terrible with GitHub.

No worries! (It's nice to hear not everyone is on closed platforms, and totally open-source workflows are viable.)

(P.S. I think GitHub is fine, for the record, but it is always good to have options than no options. And GitLab is pretty neat.)

DeeDeeG commented 6 years ago

From https://github.com/RefugeRestrooms/refugerestrooms/issues/492#issuecomment-427581913:

As @tkwidmer mentioned in Slack, we might want to also consider installing swagger-ui as a proper node package.

Our public/api directory is mostly (entirely?) a copy of the swagger-ui project from the 2.0 series: https://github.com/swagger-api/swagger-ui/tree/2.x/dist

I suspect we could install (the 2.0 version?) of the nodejs package and then update as needed.

Edit: This is PR #506. Thanks @btyy77c!

DeeDeeG commented 6 years ago

Sorry to bother you @btyy77c. (These pull requests you have put in are really helpful!)

To clarify about the commit author deatils: Does it bother you if these commits aren't linked to your GitHub account?

If so: Please let us know what e-mail should be in these commits to properly link to your account. I'm prepared to rebase the pull requests with the correct author info if that works for you. You can check what e-mails are already linked to your GitHub account (or even add another email address to your account) here: https://github.com/settings/emails

Edit: As a reminder, there is a totally anonymous email option that still links these commits to your GitHub account. That would be the username@users.noreply.github.com format.

If not, or if you'd actually prefer these commits not be linked to your account (better anonymity, etc), please let us know. That is no problem, but I'd hate to use someone's work without crediting them, or at least confirming how they do or don't want to be attributed.

Thanks again!

- DeeDeeG

btyy77c commented 6 years ago

Sorry to bother you @btyy77c. (These pull requests you have put in are really helpful!)

To clarify about the commit author deatils: Does it bother you if these commits aren't linked to your GitHub account?

If so: Please let us know what e-mail should be in these commits to properly link to your account. I'm prepared to rebase the pull requests with the correct author info if that works for you. You can check what e-mails are already linked to your GitHub account (or even add another email address to your account) here: https://github.com/settings/emails

Edit: As a reminder, there is a totally anonymous email option that still links these commits to your GitHub account. That would be the username@users.noreply.github.com format.

If not, or if you'd actually prefer these commits not be linked to your account (better anonymity, etc), please let us know. That is no problem, but I'd hate to use someone's work without crediting them, or at least confirming how they do or don't want to be attributed.

Thanks again!

  • DeeDeeG

I don't have a preference either way. I use gitlab mostly and I don't want to change my email to anything like noreply.github.com. Thanks for checking first!

DeeDeeG commented 6 years ago

Edit: I think this comment is incorrect, actually. See next comment.

Hi again,

I did get to take another look at this. The primary issue left with this pull request is the API documentation page not working.

I am pretty confident that has to do with our API being built against an older API spec, and the new grape and grape-swagger gems not being compatible with our somewhat old API.

We would need to update our actual API code to fix this; I made issue #516 to address it.

For now I'd recommend rolling back grape and grape-swagger to the versions they have in the current develop branch. That should make the API page functional again.

I'm also taking a look at the way the new config files are merged, but everything generally works as expected when I boot this up in Docker, so the config files are not likely to need changes, or else they would just be small tweaks.

Best,

- DeeDeeG

DeeDeeG commented 6 years ago

Well, the updated grape and grape-swagger gems are working in #506, so clearly our API is fundamentally compatible with the new gem versions.

I will try to see if there is any way to get the new swagger setup working on Rails 5.2.1, and if so I will update here. Then we can probably merge this and #506 once we get them working together.

DeeDeeG commented 6 years ago

For some reason, on this branch I get two requests for "/api/swagger_doc.json" every time I visit the API docs page:

Started GET "/api/swagger_doc.json" for 10.0.2.2 at 2018-10-16 02:42:03 +0000
Started GET "/api/swagger_doc.json" for 10.0.2.2 at 2018-10-16 02:42:03 +0000

Edit: This happens in develop as well.

DeeDeeG commented 6 years ago

In the process of troubleshooting this pull request, I went and performed a Rails 5.2.1 upgrade over again from scratch in this branch: https://github.com/DeeDeeG/refugerestrooms/tree/rails-5.2.1

It's a bit more minimal in terms of changes, and it does work, including the API documentation page.

I only updated the minimum amount of Gems required, didn't enable the listen Gem, and tried to keep config changes to a minimum and preserve existing custom configs, while merging the new ones from 5.2.1.

I still can't figure out why this pull request broke the API page. After all of this, I might lean toward just merging that branch. But the proof that this was easy enough to do in an afternoon, and some impetus to actually get this done, is still owed to this pull request, regardless. So thanks again.

Best regards,

- DeeDeeG

DeeDeeG commented 6 years ago

I (finally) figured out what was going on with the API page.

This branch still has the old 2.x version of swagger-ui, which only supports APIs made conforming to the Swagger 1.2 API specification...

Upgrading the grape and grape-swagger gems causes our app to serve an OpenAPI 2.0 API... which the old swagger-ui code doesn't recognize and assumes is a "deprecated" API format, ultimately failing to load.

So that match-up is what breaks the docs page. (Evidently the API itself did not break, just the page explaining the API to end-users. That's why our tests all passed anyway. I think we should add some RSpec tests to the API docs page at some point, so we test that page, and not just the raw API calls.)


In short: We can fix the API docs page for this pull request by using older grape and grape-swagger. (See this branch at my fork.)