Remove duplicate course entries from updateCourses.js

This commit is contained in:
Matt Lott 2016-08-18 15:27:06 -07:00
parent 2f220eb007
commit fb0357e0f9

View file

@ -4,8 +4,7 @@
// mongo <address>:<port>/<database> <script file> -u <username> -p <password> // mongo <address>:<port>/<database> <script file> -u <username> -p <password>
// eg: mongo localhost:27017/coco scripts/mongodb/updateCourses.js // eg: mongo localhost:27017/coco scripts/mongodb/updateCourses.js
// NOTE: uses name as unique identifier, so changing the name will insert a new course // NOTE: uses slug as unique identifier, so changing the slug will insert a new course
// NOTE: pricePerSeat in USD cents
load('bower_components/lodash/dist/lodash.js'); load('bower_components/lodash/dist/lodash.js');
var courses = var courses =
@ -96,33 +95,6 @@ var courses =
screenshot: "/images/pages/courses/105_info.png", screenshot: "/images/pages/courses/105_info.png",
releasePhase: 'released' releasePhase: 'released'
}, },
{
name: "CS: Game Development 1",
slug: "game-dev-1",
campaignID: ObjectId("5789236960deed1f00ec2ab8"),
description: "Learn to create your own games which you can share with your friends.",
duration: NumberInt(1),
free: false,
releasePhase: 'released'
},
{
name: "CS: Web Development 1",
slug: "web-dev-1",
campaignID: ObjectId("578913f2c8871ac2326fa3e4"),
description: "Learn the basics of web development in this introductory HTML & CSS course.",
duration: NumberInt(1),
free: false,
releasePhase: 'released'
},
{
name: "CS: Web Development 2",
slug: "web-dev-2",
campaignID: ObjectId("57891570c8871ac2326fa3f8"),
description: "Learn more advanced web development, including scripting to make interactive webpages.",
duration: NumberInt(2),
free: false,
releasePhase: 'beta'
},
{ {
name: "JS Primer", name: "JS Primer",
slug: "js-primer", slug: "js-primer",
@ -147,10 +119,8 @@ _.forEach(courses, function(course) {
} }
} }
course.concepts = Object.keys(concepts); course.concepts = Object.keys(concepts);
}); });
print("Updating courses.."); print("Updating courses..");
for (var i = 0; i < courses.length; i++) { for (var i = 0; i < courses.length; i++) {
db.courses.update({slug: courses[i].slug}, {$set: courses[i]}, {upsert: true}); db.courses.update({slug: courses[i].slug}, {$set: courses[i]}, {upsert: true});