Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cs_comments_service
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
cs_comments_service
Commits
cc91b3bd
Commit
cc91b3bd
authored
Jan 11, 2016
by
christopher lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed outdate index scripts, and added new scripts
parent
156456ec
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
0 additions
and
117 deletions
+0
-117
scripts/db/migrate-001-sk-author_username.js
+0
-51
scripts/db/migrate-002-update-indexes.js
+0
-6
scripts/db/migrate-003-update-indexes.js
+0
-3
scripts/db/migrate-004-update-indexes.js
+0
-2
scripts/db/migrate-005-update-indexes.js
+0
-1
scripts/db/migrate-006-remove-email.js
+0
-1
scripts/db/migrate-007-thread-type.js
+0
-7
scripts/db/migrate-008-context.js
+0
-9
scripts/db/revert-migrate-001-sk-author_username.js
+0
-6
scripts/db/revert-migrate-002-update-indexes.js
+0
-6
scripts/db/revert-migrate-003-update-indexes.js
+0
-3
scripts/db/revert-migrate-004-update-indexes.js
+0
-2
scripts/db/revert-migrate-005-update-indexes.js
+0
-1
scripts/db/revert-migrate-006-remove-email.js
+0
-1
scripts/db/revert-migrate-007-thread-type.js
+0
-7
scripts/db/revert-migrate-008-context.js
+0
-11
No files found.
scripts/db/migrate-001-sk-author_username.js
deleted
100644 → 0
View file @
156456ec
print
(
"backpopulating author_username into contents collection"
);
var
tot
=
db
.
users
.
count
();
print
(
"found "
+
tot
+
" users to process..."
);
var
cnt
=
0
;
db
.
users
.
find
({},
{
external_id
:
1
,
username
:
1
}).
forEach
(
function
(
doc
)
{
db
.
contents
.
update
(
{
author_id
:
doc
[
"external_id"
],
author_username
:{
$exists
:
false
}},
{
$set
:{
author_username
:
doc
[
"username"
]}},
{
multi
:
true
}
);
cnt
+=
1
;
if
(
cnt
==
tot
)
{
print
(
"done!"
);
}
else
if
(
cnt
%
1000
===
0
)
{
print
(
"processed "
+
cnt
+
" records ("
+
parseInt
((
cnt
/
tot
)
*
100
)
+
"% complete)"
);
}
});
print
(
"backpopulating content with orphaned author ids"
);
db
.
contents
.
update
({
author_username
:{
$exists
:
false
}},
{
$set
:{
author_username
:
null
}},
{
multi
:
true
});
print
(
"done!"
);
print
(
"backpopulating hierarchical sorting keys into contents collection"
);
var
tot
=
db
.
contents
.
find
({
"_type"
:
"Comment"
,
"sk"
:{
$exists
:
false
}}).
count
();
print
(
"found "
+
tot
+
" comments to process..."
);
var
cnt
=
0
;
db
.
contents
.
find
({
"_type"
:
"Comment"
,
"sk"
:{
$exists
:
false
}}).
forEach
(
function
(
doc
)
{
var
i
,
sort_ids
;
if
(
typeof
(
doc
.
sk
)
===
"undefined"
)
{
if
(
typeof
(
doc
.
parent_ids
)
===
"undefined"
)
{
sort_ids
=
[];
}
else
{
sort_ids
=
doc
.
parent_ids
.
slice
(
0
);
}
sort_ids
.
push
(
doc
.
_id
);
doc
.
sk
=
sort_ids
.
map
(
function
(
oid
)
{
return
oid
.
str
}).
join
(
"-"
);
db
.
contents
.
save
(
doc
);
}
cnt
+=
1
;
if
(
cnt
==
tot
)
{
print
(
"done!"
);
}
else
if
(
cnt
%
1000
===
0
)
{
print
(
"processed "
+
cnt
+
" records ("
+
parseInt
((
cnt
/
tot
)
*
100
)
+
"% complete)"
);
}
});
print
(
"creating index on new sorting keys..."
);
db
.
contents
.
ensureIndex
({
"sk"
:
1
})
print
(
"all done!"
);
scripts/db/migrate-002-update-indexes.js
deleted
100644 → 0
View file @
156456ec
db
.
contents
.
ensureIndex
({
_type
:
1
,
comment_thread_id
:
1
,
author_id
:
1
,
updated_at
:
1
},
{
background
:
true
})
db
.
contents
.
ensureIndex
({
comment_thread_id
:
1
,
sk
:
1
},
{
background
:
true
,
sparse
:
true
})
db
.
contents
.
ensureIndex
({
comment_thread_id
:
1
,
endorsed
:
1
},
{
background
:
true
,
sparse
:
true
})
db
.
contents
.
ensureIndex
({
_type
:
1
,
course_id
:
1
,
pinned
:
-
1
,
created_at
:
-
1
},
{
background
:
true
})
db
.
contents
.
dropIndex
({
sk
:
1
})
// the new one (created above) supersedes this
scripts/db/migrate-003-update-indexes.js
deleted
100644 → 0
View file @
156456ec
db
.
users
.
dropIndex
({
external_id
:
1
})
// drop the non-unique one
db
.
users
.
ensureIndex
({
external_id
:
1
},
{
unique
:
true
,
background
:
true
})
db
.
subscriptions
.
ensureIndex
({
source_id
:
1
,
source_type
:
1
},
{
background
:
true
})
scripts/db/migrate-004-update-indexes.js
deleted
100644 → 0
View file @
156456ec
db
.
contents
.
ensureIndex
({
_type
:
1
,
course_id
:
1
,
pinned
:
-
1
,
comment_count
:
-
1
,
created_at
:
-
1
},
{
background
:
true
})
db
.
contents
.
ensureIndex
({
_type
:
1
,
course_id
:
1
,
pinned
:
-
1
,
"votes.point"
:
-
1
,
created_at
:
-
1
},
{
background
:
true
})
scripts/db/migrate-005-update-indexes.js
deleted
100644 → 0
View file @
156456ec
db
.
contents
.
ensureIndex
({
commentable_id
:
1
},
{
sparse
:
true
,
background
:
true
})
scripts/db/migrate-006-remove-email.js
deleted
100644 → 0
View file @
156456ec
db
.
users
.
dropIndex
({
email
:
1
})
scripts/db/migrate-007-thread-type.js
deleted
100644 → 0
View file @
156456ec
print
(
"Adding thread_type to all comment threads where it does not yet exist
\
n"
);
db
.
contents
.
update
(
{
_type
:
"CommentThread"
,
thread_type
:
{
$exists
:
false
}},
{
$set
:
{
thread_type
:
"discussion"
}},
{
multi
:
true
}
);
printjson
(
db
.
runCommand
({
getLastError
:
1
,
w
:
"majority"
,
wtimeout
:
5000
}
));
scripts/db/migrate-008-context.js
deleted
100644 → 0
View file @
156456ec
print
(
"Add the new indexes for the context field"
);
db
.
contents
.
ensureIndex
({
_type
:
1
,
course_id
:
1
,
context
:
1
,
pinned
:
-
1
,
created_at
:
-
1
},
{
background
:
true
})
db
.
contents
.
ensureIndex
({
_type
:
1
,
commentable_id
:
1
,
context
:
1
,
pinned
:
-
1
,
created_at
:
-
1
},
{
background
:
true
})
print
(
"Adding context to all comment threads where it does not yet exist
\
n"
);
var
bulk
=
db
.
contents
.
initializeUnorderedBulkOp
();
bulk
.
find
(
{
_type
:
"CommentThread"
,
context
:
{
$exists
:
false
}}
).
update
(
{
$set
:
{
context
:
"course"
}}
);
bulk
.
execute
();
printjson
(
db
.
runCommand
({
getLastError
:
1
,
w
:
"majority"
,
wtimeout
:
5000
}
));
scripts/db/revert-migrate-001-sk-author_username.js
deleted
100644 → 0
View file @
156456ec
print
(
"removing fields 'sk' and 'author_username' from contents collection..."
);
db
.
contents
.
update
({},
{
$unset
:{
"sk"
:
1
,
"author_username"
:
1
}},
{
multi
:
true
});
print
(
"removing index on contents.sk"
);
db
.
contents
.
dropIndex
({
"sk"
:
1
});
print
(
"all done!"
);
scripts/db/revert-migrate-002-update-indexes.js
deleted
100644 → 0
View file @
156456ec
db
.
contents
.
ensureIndex
({
sk
:
1
},
{
background
:
true
,
safe
:
true
})
db
.
contents
.
dropIndex
({
comment_thread_id
:
1
,
updated_at
:
1
})
db
.
contents
.
dropIndex
({
comment_thread_id
:
1
,
sk
:
1
})
db
.
contents
.
dropIndex
({
comment_thread_id
:
1
,
endorsed
:
1
})
db
.
contents
.
dropIndex
({
_type
:
1
,
course_id
:
1
,
pinned
:
-
1
,
created_at
:
-
1
})
scripts/db/revert-migrate-003-update-indexes.js
deleted
100644 → 0
View file @
156456ec
db
.
users
.
dropIndex
({
external_id
:
1
})
// drop the unique one
db
.
users
.
ensureIndex
({
external_id
:
1
},
{
background
:
true
})
db
.
subscriptions
.
dropIndex
({
source_id
:
1
,
source_type
:
1
})
scripts/db/revert-migrate-004-update-indexes.js
deleted
100644 → 0
View file @
156456ec
db
.
contents
.
dropIndex
({
_type
:
1
,
course_id
:
1
,
pinned
:
-
1
,
comment_count
:
-
1
,
created_at
:
-
1
})
db
.
contents
.
dropIndex
({
_type
:
1
,
course_id
:
1
,
pinned
:
-
1
,
"votes.point"
:
-
1
,
created_at
:
-
1
})
scripts/db/revert-migrate-005-update-indexes.js
deleted
100644 → 0
View file @
156456ec
db
.
contents
.
dropIndex
({
commentable_id
:
1
})
scripts/db/revert-migrate-006-remove-email.js
deleted
100644 → 0
View file @
156456ec
db
.
users
.
ensureIndex
({
email
:
1
},
{
background
:
true
})
scripts/db/revert-migrate-007-thread-type.js
deleted
100644 → 0
View file @
156456ec
print
(
"Removing thread_type from all comment threads
\
n"
);
db
.
contents
.
update
(
{
_type
:
"CommentThread"
},
{
$unset
:
{
thread_type
:
""
}},
{
multi
:
true
}
);
printjson
(
db
.
runCommand
({
getLastError
:
1
,
w
:
"majority"
,
wtimeout
:
5000
}
));
scripts/db/revert-migrate-008-context.js
deleted
100644 → 0
View file @
156456ec
print
(
"remove the indexes for the context field"
);
db
.
contents
.
dropIndex
({
_type
:
1
,
course_id
:
1
,
context
:
1
,
pinned
:
-
1
,
created_at
:
-
1
})
db
.
contents
.
dropIndex
({
_type
:
1
,
commentable_id
:
1
,
context
:
1
,
pinned
:
-
1
,
created_at
:
-
1
})
print
(
"Removing context from all comment threads
\
n"
);
db
.
contents
.
update
(
{
_type
:
"CommentThread"
},
{
$unset
:
{
context
:
""
}},
{
multi
:
true
}
);
printjson
(
db
.
runCommand
({
getLastError
:
1
,
w
:
"majority"
,
wtimeout
:
5000
}
));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment