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

Aliases should be re-thought: Inflates/confuses stats; slightly brittle #16

Open
alanhogan opened this issue Apr 9, 2012 · 0 comments

Comments

@alanhogan
Copy link
Owner

Problems with the Status Quo

  1. Expanding short URLs that are aliases of another — of which at least one always exists when any URL is saved as more than one slug — currently increments its own stats & those of the canonical URL.
  2. It looks funny on the stats page (even besides the fact that, given Trim bad characters from the right of URLs #1, such stats will in fact be misleading)
  3. If a slug that is currently canonical for some URL, and it has aliases, but then the slug is redefined, the alias slugs are implicitly redefined as well. (Not that redefining slugs is a smart idea.)

Stats page oddness


Original rationale / current implementation

If a URL is shrunk to the slug “a” and then later manually assigned the slug “b,” the entry for slug “a” is rewritten to be an alias (internal redirect) for slug “b.”

The reason this was done is so that when Lessn More is asked for a short URL for the original URL later, it returns the one that was manually assigned (“b”).

However, I’m not wholly convinced this is a smart arrangement anymore — it would be stupid, but what if “b” was later re-assigned to a new URL? Then “a” would change, too (as an alias for “b”). You shouldn’t change short URLs anyway, but is that the right thing to do?


A Better Way?

Probably a better idea is to add a boolean (slash tinyint) field that would designate “b” as the canonical short URL. The query used to retrieve a slug for the original URL would prefer but not require slugs with the canonical flag. This would have the following effects:

  • No longer would it take more than one SQL query to follow a non-canonical URL
  • Aliases would no longer increment the stats for multiple slugs, as they currently do
  • The stats page would not have trouble showing aliases anymore.

Obviously a database migration would be required.


Another thought

The double-increment of stats however sounds like a bug that could be worked out without necessarily requiring a database migration.

Likewise the stats page could be improved to show aliases more accurately and/or show the long URL as normal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant