Commit c8695c8d authored by Daniel Gerhardt's avatar Daniel Gerhardt

Update CouchDB design docs

parent 5541bbf8
var designDoc = {
"_id": "_design/answer",
"_id": "_design/Answer",
"language": "javascript",
"views": {
"doc_by_questionid_user_piround": {
"by_questionid": {
"map": function (doc) {
if (doc.type === "skill_question_answer") {
emit([doc.questionId, doc.user, doc.piRound], doc);
emit(doc.questionId, {_rev: doc._rev});
}
}
},
"doc_by_questionid_timestamp": {
"by_questionid_piround_text_subject": {
"map": function (doc) {
if (doc.type === "skill_question_answer") {
emit([doc.questionId, doc.timestamp], doc);
emit([doc.questionId, doc.piRound, doc.abstention, doc.answerText, doc.answerSubject, doc.successfulFreeTextAnswer], {_rev: doc._rev});
}
}
},
"reduce": "_count"
},
"doc_by_user_sessionid": {
"by_questionid_timestamp": {
"map": function (doc) {
if (doc.type === "skill_question_answer") {
emit([doc.user, doc.sessionId], doc);
emit([doc.questionId, doc.timestamp], {_rev: doc._rev});
}
}
},
"by_questionid": {
"by_questionid_user_piround": {
"map": function (doc) {
if (doc.type === "skill_question_answer") {
emit(doc.questionId, null);
emit([doc.questionId, doc.user, doc.piRound], {_rev: doc._rev});
}
}
},
"by_questionid_piround_text_subject": {
"by_sessionid": {
"map": function (doc) {
if (doc.type === "skill_question_answer") {
emit([doc.questionId, doc.piRound, doc.abstention, doc.answerText, doc.answerSubject, doc.successfulFreeTextAnswer], null);
emit(doc.sessionId, {_rev: doc._rev});
}
},
"reduce": "_count"
},
"by_sessionid": {
/* Redundant view but kept for now to allow simpler queries. */
"by_sessionid_variant": {
"map": function (doc) {
if (doc.type === "skill_question_answer") {
emit(doc.sessionId, null);
emit([doc.sessionId, doc.questionVariant], {_rev: doc._rev});
}
},
"reduce": "_count"
},
"by_sessionid_variant": {
"by_user_sessionid": {
"map": function (doc) {
if (doc.type === "skill_question_answer") {
emit([doc.sessionId, doc.questionVariant], null);
emit([doc.user, doc.sessionId], {_rev: doc._rev});
}
},
"reduce": "_count"
}
},
"questionid_by_user_sessionid_variant": {
"map": function (doc) {
......
var designDoc = {
"_id": "_design/comment",
"_id": "_design/Comment",
"language": "javascript",
"views": {
"doc_by_sessionid_creator_timestamp": {
"by_sessionid": {
"map": function (doc) {
if (doc.type === "interposed_question") {
emit([doc.sessionId, doc.creator, doc.timestamp], doc);
emit(doc.sessionId, {_rev: doc._rev});
}
}
},
"reduce": "_count"
},
"doc_by_sessionid_timestamp": {
"by_sessionid_creator_read": {
"map": function (doc) {
if (doc.type === "interposed_question") {
emit([doc.sessionId, doc.timestamp], doc);
emit([doc.sessionId, doc.creator, doc.read], {_rev: doc._rev})
}
}
},
"reduce": "_count"
},
"by_sessionid": {
/* Redundant view but kept for now to allow simpler queries. */
"by_sessionid_creator_timestamp": {
"map": function (doc) {
if (doc.type === "interposed_question") {
emit(doc.sessionId, null);
emit([doc.sessionId, doc.creator, doc.timestamp], {_rev: doc._rev});
}
},
"reduce": "_count"
}
},
"by_sessionid_read": {
"map": function (doc) {
if (doc.type === "interposed_question") {
emit([doc.sessionId, doc.read], null);
emit([doc.sessionId, doc.read], {_rev: doc._rev});
}
},
"reduce": "_count"
},
"by_sessionid_creator_read": {
"by_sessionid_timestamp": {
"map": function (doc) {
if (doc.type === "interposed_question") {
emit([doc.sessionId, doc.creator, doc.read], null);
emit([doc.sessionId, doc.timestamp], {_rev: doc._rev});
}
},
"reduce": "_count"
}
}
}
};
var designDoc = {
"_id": "_design/content",
"_id": "_design/Content",
"language": "javascript",
"views": {
"doc_by_sessionid_variant_active": {
"map": function (doc) {
if (doc.type === "skill_question") {
emit([doc.sessionId, doc.questionVariant, doc.active, doc.subject, doc.text.substr(0, 16)], doc);
}
},
"reduce": "_count"
},
"by_sessionid": {
/* Redundant view but kept for now to allow simpler queries. */
"map": function (doc) {
if (doc.type === "skill_question") {
emit(doc.sessionId, null);
emit(doc.sessionId, {_rev: doc._rev});
}
},
"reduce": "_count"
......@@ -22,7 +13,7 @@ var designDoc = {
"by_sessionid_variant_active": {
"map": function (doc) {
if (doc.type === "skill_question") {
emit([doc.sessionId, doc.questionVariant, doc.active, doc.subject, doc.text.substr(0, 16)], null);
emit([doc.sessionId, doc.questionVariant, doc.active, doc.subject, doc.text.substr(0, 16)], {_rev: doc._rev});
}
},
"reduce": "_count"
......
var designDoc = {
"_id": "_design/user",
"_id": "_design/DbUser",
"language": "javascript",
"views": {
"doc_by_username": {
"map": function (doc) {
if (doc.type === "userdetails") {
emit(doc.username, doc);
}
}
},
"by_creation_for_inactive": {
"map": function (doc) {
if (doc.type === "userdetails" && doc.activationKey) {
emit(doc.creation, {_rev: doc._rev});
}
}
},
"by_username": {
"map": function (doc) {
if (doc.type === "userdetails") emit(doc.username, {_rev: doc._rev});
}
}
}
};
var designDoc = {
"_id": "_design/logged_in",
"_id": "_design/LoggedIn",
"language": "javascript",
"views": {
"visited_sessions_by_user": {
"map": function (doc) {
if (doc.type === "logged_in") {
emit(doc.user, doc.visitedSessions);
}
}
},
"all": {
"map": function (doc) {
if (doc.type === "logged_in"){
......@@ -22,6 +15,13 @@ var designDoc = {
emit(doc.timestamp || 0, {_rev: doc._rev});
}
}
},
"visited_sessions_by_user": {
"map": function (doc) {
if (doc.type === "logged_in") {
emit(doc.user, doc.visitedSessions);
}
}
}
}
};
var designDoc = {
"_id": "_design/motd",
"_id": "_design/Motd",
"language": "javascript",
"views": {
"doc_by_sessionkey": {
"by_audience_for_global": {
"map": function (doc) {
if (doc.type === "motd" && doc.audience === "session") {
emit(doc.sessionkey, doc);
if (doc.type === "motd" && doc.audience !== "session") {
emit(doc.audience, {_rev: doc._rev});
}
}
},
"doc_by_audience_for_global": {
"by_motdkey": {
"map": function (doc) {
if (doc.type === "motd" && doc.audience !== "session") {
emit(doc.audience, doc);
if (doc.type === "motd") {
emit(doc.motdkey, {_rev: doc._rev});
}
}
},
"by_motdkey": {
"by_sessionkey": {
"map": function (doc) {
if (doc.type === "motd") {
emit(doc.motdkey, doc);
if (doc.type === "motd" && doc.audience === "session") {
emit(doc.sessionkey, {_rev: doc._rev});
}
}
}
......
var designDoc = {
"_id": "_design/motdlist",
"_id": "_design/MotdList",
"language": "javascript",
"views": {
"doc_by_username": {
......
var designDoc = {
"_id": "_design/session",
"_id": "_design/Session",
"language": "javascript",
"views": {
"by_courseid": {
"map": function (doc) {
if (doc.type === "session" && doc.courseId && doc.sessionType !== "public_pool") {
emit(doc.courseId, null);
if (doc.type === "session" && doc.courseId && doc.sessionType !== "public_pool") {
emit(doc.courseId, {_rev: doc._rev});
}
}
},
"by_keyword": {
"map": function (doc) {
if (doc.type === "session") {
emit(doc.keyword, null);
emit(doc.keyword, {_rev: doc._rev});
}
}
},
"by_lastactivity_for_guests": {
"map": function (doc) {
if (doc.type === "session" && doc.sessionType !== "public_pool" && doc.creator.indexOf("Guest") === 0) {
emit(doc.lastOwnerActivity || doc.creationTime, {_rev: doc._rev});
}
}
},
......@@ -29,9 +36,9 @@ var designDoc = {
}
}
},
"partial_by_ppsubject_name_for_publicpool": {
"partial_by_subject_name_for_publicpool": {
"map": function (doc) {
if (doc.type === "session" && doc.sessionType === "public_pool") {
if (doc.type === "session" && doc.sessiontype === "public_pool") {
emit([doc.ppSubject, doc.name], {
ppSubject: doc.ppSubject,
name: doc.name,
......@@ -40,13 +47,6 @@ var designDoc = {
});
}
}
},
"by_lastactivity_for_guests": {
"map": function (doc) {
if (doc.type === "session" && doc.sessionType !== "public_pool" && doc.creator.indexOf("Guest") === 0) {
emit(doc.lastOwnerActivity || doc.creationTime, {_rev: doc._rev});
}
}
}
}
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment