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

Stop manually slugifying PLC course names #30779

Merged
merged 8 commits into from Sep 17, 2019
Merged

Conversation

islemaster
Copy link
Contributor

PLC-452: Some of our PLC course links (including breadcrumbs) are broken (Slack) because we've been manually slug-ifying the PLC course names for our URLs with:

name.downcase.tr(' ', '-')

...and trying to restore them with...

name.tr('-', '_').titleize

This worked fine for the one simple test case we had in place (My Plc <=> my_plc) but our real course names don't look like that. A recent broken example:

# The real course name
"CS Discoveries Deeper Learning 2019 - 2020"
# Slug-ified
"cs-discoveries-deeper-learning-2019---2020"
# Unsuccessfully restored
"Cs Discoveries Deeper Learning 2019   2020"

This PR removes the "slugification" code and replaces it with a more typical use of the course_path helper, passing it a Course model and letting it perform all the appropriate URL encoding so that the links work fine when they're used later.

I've left the following "un-slug" code in place for now, in case there are any links or bookmarks out there still depending on the old behavior:

course = Course.get_from_cache(params[:course_name])
unless course
# PLC courses have different ways of getting to name. ideally this goes
# away eventually
course_name = params[:course_name].tr('-', '_').titleize
course = Course.get_from_cache(course_name)
# only support this alternative course name for plc courses
raise ActiveRecord::RecordNotFound unless course.try(:plc_course)
end

We'll watch for remaining uses of this path and remove it when we're confident it's no longer needed.

Copy link
Member

@breville breville left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link
Contributor

@maddiedierker maddiedierker left a comment

Choose a reason for hiding this comment

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

yay for doing less!

do-less.gif

@islemaster islemaster merged commit a929d44 into staging Sep 17, 2019
@islemaster islemaster deleted the plc-course-names branch September 17, 2019 23:33
islemaster added a commit that referenced this pull request Jun 17, 2020
This change removes some unneeded CoursesController logic.

Prior to September 2019, we had a system in place that would "slug-ify" PLC course names in generated links.  For example: A course named `Professional Learning` would be slugified to `professional-learning` for urls.  We also had code in CoursesController to "un-slug-ify" these course names so the appropriate course could be loaded.

Unfortunately, our course names got more complicated and this system wasn't able to handle them well.  Here's a known broken case:

```
// The real course name
"CS Discoveries Deeper Learning 2019 - 2020"
// Slug-ified
"cs-discoveries-deeper-learning-2019---2020"
// Unsuccessfully restored
"Cs Discoveries Deeper Learning 2019   2020"
```

Nine months ago we [removed this slugification logic](#30779); now we simply urlencode course names. At the time, we left the unslug logic in with a Honeybadger notification, to avoid breaking existing links and to monitor how much use this system was seeing.

In the last nine months we have seen slugified PLC course links used a total of 89 times, and only for the `CSP Support` course.  Nobody among developers or PLC partners has been able to track down where such a link still exists in our system.  Andrea shared that this is an old course, and that link should not be used by anyone except a former participant trying to review their answers.

I propose that it's time to deprecate this logic, which unnecessarily complicates our course routing.  If anyone contacts us about the `csp-support` link, we can handle this manually and share an updated link with them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants