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

Add a script to reindex files or change how we id #121

Closed
bagelbits opened this issue Dec 10, 2019 · 13 comments
Closed

Add a script to reindex files or change how we id #121

bagelbits opened this issue Dec 10, 2019 · 13 comments
Assignees

Comments

@bagelbits
Copy link
Collaborator

This would probably be an all or nothing script as it would need to reindex associations as well.

Alternatively, we could set ids to not be sequential numbers. Instead have them be something random. Something akin to a UUID comes to mind. This would avoid needing to reindex ever again. But there needs to be a standard way to generate a new id.

@ogregoire @Alex-frazer Thoughts?

@bagelbits
Copy link
Collaborator Author

This is coming off of a short discussion here: #119

@ogregoire
Copy link
Collaborator

ogregoire commented Dec 10, 2019

For id, I'd just use the name and normalize it with regexes, like this:

  1. Use the language's "to lowercase" function.
  2. Delete unwanted characters such as initial and final whitespaces, as well as apostrophes inside words: (?:(?<=\bo)'|'(?=s\b)|^\W+|\W+$)
  3. Replace sequences of non letters with a single dash: \W+ to -.

This has the advantage to be deterministic and usually unique because, in the SRD, names are unique.

I think regexes are a good fit because they can be used in any language so no matter the scripting language, it will just work. Also, those regex can be simplified or aggregated, but I haven't found a single regex to do all that at once.

@bagelbits
Copy link
Collaborator Author

I think that's a reasonable ID pattern.

@bagelbits
Copy link
Collaborator Author

So that would convert Arcanist's Magic Aura into arcanists-magic-aura. Yeah. I definitely like that.

@bagelbits
Copy link
Collaborator Author

I just hope that doesn't break anything for anyone.

@ogregoire
Copy link
Collaborator

I just hope that doesn't break anything for anyone.

That will definitely break something for someone. But keeping changing the ids because we remove or add stuff will also definitely break something for someone.

The change will break everything for everyone, but after that nothing will break for no one.

@bagelbits
Copy link
Collaborator Author

If we're going to do this, we may as well drop the domain from the URL as well.

@bagelbits
Copy link
Collaborator Author

Actually, that would be a pretty good use for a repository tag. Since essentially that would be a major version change.

@bagelbits
Copy link
Collaborator Author

@ogregoire If you want to pull the trigger on this, feel free to. I think I'm about to have my hands full.

@bagelbits
Copy link
Collaborator Author

I added a PR to address #113 which drops the domain from the URLs.

@bagelbits
Copy link
Collaborator Author

I also started throwing together a script to do the ID conversion.

@bagelbits
Copy link
Collaborator Author

Well. That might do it but I probably messed something up.

@bagelbits
Copy link
Collaborator Author

Okay. I think this PR is in a good state for adding string ids.

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

2 participants