Closed codersquid closed 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.
@codersquid If you don't want to work on this, I can finish it up. Either way is fine by me.
I'm closing this and making a pull request from another branch, see #269
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.
oh and yeah you are right about the annoying corner cases with the counting approach.
Sorry for the lateness--I plan to review this sometime this week.
Whoops--wrong pr. :p
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