pyvideo / richard

video indexing site
Other
216 stars 55 forks source link

slug length counter bumps slug over max_length limit #254

Closed codersquid closed 9 years ago

codersquid commented 10 years ago

When creating multiple videos with the same title, the unique counter appended to the slug bumps the entire thing over the max_length of 50 chars. related to #249

willkg commented 9 years ago

Another way to do this is to hash the date with sha1 encode it with base16 and then take the first x characters (7 or 8 is probably sufficient) and use that. It reduces the likelihood you have to do multiple iterations because it doesn't have the problem that incrementing a counter has. However, it uses 7 or 8 characters.

I think this is probably the way to go.

willkg commented 9 years ago

@codersquid If you don't want to work on this, I can finish it up. Either way is fine by me.

codersquid commented 9 years ago

I'm closing this and making a pull request from another branch, see #269

codersquid commented 9 years ago

I decided not to do the hash based on time because of collisions when doing batch creations -- the calls happen in under a second, and time.time() or datetime.datetime.now() don't have enough resolution. but I could be wrong! I searched a little just to see. Doesn't seem so. Instead of getting carried away and using a random seed and blah blah I went back to the loop thing.

codersquid commented 9 years ago

oh and yeah you are right about the annoying corner cases with the counting approach.

willkg commented 9 years ago

Sorry for the lateness--I plan to review this sometime this week.

willkg commented 9 years ago

Whoops--wrong pr. :p