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

Deprecate route format, replacing with pattern #3329

Open
paulmelnikow opened this issue Apr 17, 2019 · 4 comments
Open

Deprecate route format, replacing with pattern #3329

paulmelnikow opened this issue Apr 17, 2019 · 4 comments
Labels
core Server, BaseService, GitHub auth, Shared helpers service-badge New or updated service badge

Comments

@paulmelnikow
Copy link
Member

To make the code easier to understand and to support trie-based routing for #3328, it would be helpful to replace the several remaining instances of route formats with patterns.

Many of the remaining formats are designed to support aliases, and since we've started using redirects heavily, the likely solution is to rewrite the canonical form using a pattern, and add redirects for each of the alias forms.

Ideally by using multiple redirects we can rewrite everything using patterns.

@paulmelnikow paulmelnikow added the core Server, BaseService, GitHub auth, Shared helpers label Apr 17, 2019
paulmelnikow added a commit that referenced this issue Apr 18, 2019
paulmelnikow added a commit that referenced this issue Apr 22, 2019
- Prefer inline transforms to take place in `handle()` rather than `render()`
- Avoid inversion of control by removing `BaseWordpress#handle()`, passing `extensionType` into `fetch()`, and removing one layer of subclassing
- Move “not found” checks into `fetch()`
- Cache wordpress versions instead of fetching on each request
- Start to convert aliases to redirects (there are more of these which could be tackled in a follow-on)
- Replace at least one route `format` with a `pattern` (ref #3329)
- Partially reorder: name, category, route, examples, defaultBadgeData, render, fetch, handle

Some of this is in line with our established patterns or makes it clearly easier to follow; some of it is arguably stylistic.
paulmelnikow added a commit that referenced this issue Jul 6, 2019
This now relies on the order in which these are registered, though that seems okay. Exporting them as an array guarantees that.

Ref #3329
paulmelnikow added a commit that referenced this issue Jul 7, 2019
This now relies on the order in which these are registered, though that seems okay. Exporting them as an array guarantees that.

Ref #3329
@paulmelnikow
Copy link
Member Author

With the PRs for #3714 merged, outside of legacy redirectors there aren't many of these left!

@paulmelnikow paulmelnikow added the service-badge New or updated service badge label Sep 17, 2019
@calebcartwright
Copy link
Member

One of the last remaining non-redirect ones is Wercker. I've sat down twice now to attempt to convert but it's a bit of an 👀 popper.

static get route() {
return {
base: 'wercker',
format:
'(?:(?:ci/)([a-fA-F0-9]{24})|(?:build|ci)/([^/]+/[^/]+?))(?:/(.+?))?',
capture: ['projectId', 'applicationName', 'branch'],
}
}

Based on the dialog in #2076, my sense is that there's two different types of build status we support from Wercker that require two different types of input (one an ID and the other the user/app name combo).

I'm thinking it might be easiest to split these in two, at least the service route definitions, with a base class/reusable functions for all the common bits.

Does that sound reasonable?

@chris48s
Copy link
Member

chris48s commented Oct 4, 2019

There's an explanation of why splitting it is hard at #2279 (comment) Once you split them into 2 services, we can't control the order the routes get matched in.

That said, as a related issue, what we're doing on the wercker badge is also a bit strange anyway (see point 3 on #2103 ). One of the routes that exists does an unexpected thing for legacy compatibility reasons.

At the time we did that, we had no idea how many users might be relying on the wercker badges, but now we have stats we know that we've served less than 1,000 total requests for the wercker badges in the last month.

Given all that, I'd be happy to:

  • re-organise the routes for wercker so we can implement them all unambiguously with patterns
  • make the URLs match the content in all cases
  • set up redirects as far as possible
  • accept some badges are going to break for a small number of users

@paulmelnikow
Copy link
Member Author

Another of these where we're still using a format is Travis. We're using a negative lookahead to prevent matching php-v, along with an optional domain component. I'd suggest we resolve this one by making the domain org|com required, and adding a redirector with the legacy format.

repo-ranger bot pushed a commit that referenced this issue Oct 16, 2020
* Change [issuestats] redirector from format to pattern

Ref #3329

* Match other services where this approach was taken
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Server, BaseService, GitHub auth, Shared helpers service-badge New or updated service badge
Projects
None yet
Development

No branches or pull requests

3 participants