Skip to content
This repository has been archived by the owner on Jul 6, 2021. It is now read-only.

Commit

Permalink
Make testing URL more stable by using content-hash for course id
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Balmer committed Jul 9, 2013
1 parent 170c4f6 commit d40049f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions server/server.js
Expand Up @@ -175,13 +175,20 @@ function createCourses(){

_.each(testcourses, function(course) {
if (!course.createdby) return; // Don't create courses that don't have an creator name

// allways use same id for same course to avoid broken urls while testing
var crypto = Npm.require('crypto'), m5 = crypto.createHash('md5');
m5.update(course.name);
m5.update(course.description);
course._id = m5.digest('hex').substring(0, 8)

for (var i=0; i < course.categories.length; i++) {
course.categories[i] = ensureCategory(course.categories[i])._id
}
course.createdby = ensureUser(course.createdby)._id
course.score = Math.floor(Random.fraction()*20)
course.subscribers_min= Math.floor(Random.fraction()*7)
course.subscribers_max= course.subscribers_min + Math.floor(Random.fraction()*20)
course.score = Math.floor(Random.fraction()*Random.fraction()*30)
course.subscribers_min = Math.floor(Random.fraction()*Random.fraction()*30)
course.subscribers_max = course.subscribers_min + Math.floor(Random.fraction()*20)
course.subscribers = []
course.time_created = new Date(new Date().getTime()-Math.floor(Random.fraction()*40000000000))
Courses.insert(course)
Expand Down

0 comments on commit d40049f

Please sign in to comment.