-
Notifications
You must be signed in to change notification settings - Fork 32
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
[chore] Fixes #42 - Import old wordpress data and convert to markdown… #98
Conversation
waiting for #83 to be merged before finishing it up |
fff419d
to
57c4060
Compare
@@ -11,7 +11,11 @@ | |||
devise_for :users | |||
|
|||
resources :events, only: [:index, :show] | |||
|
|||
# NewsItem compatibility with old wordpress Posts url | |||
get "/:year/:month/:slug", to: "news_items#show", constraints: { year: /\d{4}/, month: /\d{2}/ } |
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.
Line is too long. [98/80]
baffaf6
to
2aca4d1
Compare
# NOTE: [legacy] | ||
# - This is also where we imported the old wordpress posts | ||
# - The `slug` is purely used to store the old wordpress slug and make sure we | ||
# can still resolve: http://www.montrealrb.com/[post_date:YYYY]/[post_date:MM]/[post_name] |
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.
Line is too long. [92/80]
@montrealrb/organizers If anyone of you is interested to do a code-review and merge that PR, it takes care of the following:
Note: you will noticed that I imported all the posts from wordpress (hopefully) but that I only marked the 10 most recent, because some manual markdown cleanup work will need to be done, and I think we should focus on the most recent posts for launch and after that work our way back... |
code reviewer, please assign the PR to yourself... |
Will also Fix #99 |
2aca4d1
to
da082c6
Compare
get :index | ||
end | ||
|
||
it "populates an array of news_items with the most recently published first" do |
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.
Line is too long. [83/80]
@montrealrb/organizers I did a quick review, but don't want to take the responsibility of merging this... Anyone else up for it ? |
@news_item = NewsItem.published.find(params[:id]) | ||
@news_item = news_item_scope.where(slug: params[:slug]).first || | ||
news_item_scope.where(id: params[:id]).first || | ||
raise(ActiveRecord::RecordNotFound) |
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.
@benichu Could we extract as a method and pushed into the model? e.g.
NewsItem.fetch_published!(params[:id], params[:slug])
This allow to document the method, as I'm unsure why this is required.
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.
Sure. The reason why it's required is to still resolve old wordpress links (ex: if someone clicks on an post url from google)
I'll extract that logic into a tested and documented class method tonight or later today...
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.
Gotcha, we probably should do a redirect to the correct URL, but let's do that as a separate PR.
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 are right, just created a ticket for that #151
Until then, I am also going to leave the object loading methods as-is in the controller, I'll just add a comment to the method.
records = YAML.load_file "#{Rails.root}/db/legacy.yml" | ||
records.each do |data| | ||
news_item = NewsItem.new | ||
published_at = data["post_date"] |
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.
@benichu Since there's a couple of changes that need to be made, how would you feel call #fetch on these?
data.fetch("post_date")
I like exceptions thrown when the key I expect doesn't exist.
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.
published_at
could be nil, if the original post is a draft (which will not happen with the collection I am parsing, as the original query generated only published posts with a date). So it's not really necessary to catch the non-existence of that key.
NOTE: It's a one-off task anyway
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.
Not quite what I meant -- the key should exists, but the value might be nil :-) I should have clarified that this would be for all keys we're accessing in the hash. But happy to move on given it's a one-off task.
Awesome, @benichu! I ran this locally -- looks like we got us a site :-) |
Cool, I'll do a couple of the fixes you mentioned and we are good to merge, talk to you later... |
a96d5f9
to
0806774
Compare
@nicholasjhenry rebased, I'll merge tomorrow morning. |
Haha you have to rebase again 😛 |
… [WIP] - Generate a wordpress database dump in db/legacy.yml - Create a rake task to import that legacy data in the news_items table - Add some unit and controller specs for NewsItem - Deal with legacy urls: /YYYY/mm/a-wordpress-slug
0806774
to
3cfb664
Compare
[chore] Fixes #42 - Import old wordpress data and convert to markdown…
Left TODOS:
.published
PROBLEMS: