Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MixedModulestore wraps most getters, update_item, delete_item #2356

Merged
merged 4 commits into from
Feb 10, 2014

Conversation

dmitchell
Copy link
Contributor

with code to translate between addressing schemes based on app
and persistence layer addressing scheme specification.

STUD-1206

@singingwolfboy @cahrens Can you go ahead and review this. I still need to refactor some of the caching logic to ensure it performs ok in production. When I add that, I'll add cale and ormsbee to the reviewers.

The big change here is refactoring update_item to take an xblock and persist all of it's changes to the db rather than having the caller use update_[item|children|metadata] w/ location and json.

The purpose of this PR; however, is the titular description.

@@ -1360,6 +1355,16 @@ def definition_locator(self, definition):
else:
return DefinitionLocator(definition['_id'])

def get_modulestore_type(self, course_id):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change, just moved up to the "public methods" part of the file. It was in the midst of the underscored private methods.

@dmitchell
Copy link
Contributor Author

@cahrens @singingwolfboy I think this is ready to merge. It passed performance tests and unit tests. I'll rebase it. (Rebase is not trivial. I'll resume first thing in the morning)

@dmitchell
Copy link
Contributor Author

Oh, and I'm doing a subsequent PR which tests all of the paths in mixed ms as a separate PR.

Don Mitchell added 3 commits February 5, 2014 09:34
with code to translate between addressing schemes based on app
and persistence layer addressing scheme specification.

STUD-1206
@@ -179,7 +179,7 @@ def primitive_delete(course, num):
# Note for future implementations: if you delete a static_tab, then Chris Dodge
# points out that there's other stuff to delete beyond this element.
# This code happens to not delete static_tab so it doesn't come up.
modulestore('direct').update_metadata(course.location, own_metadata(course))
modulestore('direct').update_item(course, '**replace_user**')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have not already, please create a story (in database arch epic) for fixing these replace_user instances.

@singingwolfboy
Copy link
Contributor

Why does store.update_item take an integer user ID, instead of a user object? Seems like it would be better to throw around user objects, rather than IDs that refer to user objects. (There's plenty of other code that this PR touches that passes user objects around.)

altered_grader = CourseGradingModel.fetch(self.course_locator)
self.assertDictEqual(test_grader.grade_cutoffs, altered_grader.grade_cutoffs, "cutoff change 'Pass'")

def test_delete_grace_period(self):
test_grader = CourseGradingModel.fetch(self.course_locator)
CourseGradingModel.update_grace_period_from_json(self.course_locator, test_grader.grace_period)
CourseGradingModel.update_grace_period_from_json(
self.course_locator, test_grader.grace_period, self.user)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move the closing parenthesis onto its own line? It's more readable that way.

CourseGradingModel.update_grace_period_from_json(
    self.course_locator, test_grader.grace_period, self.user,
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all a matter of convention and opinion, but sure. I get tired of 3 lines per expression just to do a line wrap.

@@ -158,7 +158,7 @@ def delete_course_update(location, update, passed_id):
# update db record
course_updates.data = html.tostring(course_html_parsed)
store = modulestore('direct')
store.update_item(location, course_updates.data)
store.update_item(course_updates, user.id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to check if user is None?

@dmitchell
Copy link
Contributor Author

@cahrens @cpennington @singingwolfboy I've submitted my changes in response to the review comments. Please approve.

@cahrens
Copy link

cahrens commented Feb 5, 2014

👍

@singingwolfboy
Copy link
Contributor

I'm still not happy about passing user to some functions and user.id in others, but if you'll come back to it in a subsequent pull request, I'm OK with this going in as it is. 👍

dmitchell added a commit that referenced this pull request Feb 10, 2014
MixedModulestore wraps most getters, update_item, delete_item
@dmitchell dmitchell merged commit 16f0d12 into master Feb 10, 2014
@jzoldak jzoldak deleted the dhm/mixed_ms_wrapper branch May 5, 2014 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants