Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3122)

Issue 61720043: Add an index for db.charms.

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 2 months ago by bac
Modified:
10 years, 2 months ago
Reviewers:
j.c.sackett, mp+205655
Visibility:
Public.

Description

Add an index for db.charms. Without the proper index, sorting mongo results fail. * Add setup_mongo_indices and make it idempotent. * Lots of tests. * Change migration 'initialize' to call setup_mongo_indices. * Add a migration for existing dbs. * Drive by ugliness The migration scripts, even long-lived ones like test_migrations.py, were quite dirty lint-wise. Turns out the Makefile was excluding them explicitly. Changed the lint target and then had to fix the old scripts. https://code.launchpad.net/~bac/charmworld/bug-1278222/+merge/205655 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 12

Patch Set 2 : Add an index for db.charms. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+184 lines, -302 lines) Patch
M Makefile View 1 chunk +1 line, -1 line 0 comments Download
A [revision details] View 1 1 chunk +2 lines, -0 lines 0 comments Download
M charmworld/migrations/migrate.py View 1 7 chunks +73 lines, -14 lines 0 comments Download
M charmworld/migrations/test_migrate.py View 1 7 chunks +33 lines, -10 lines 0 comments Download
M charmworld/migrations/versions/019_fixed_mapping_for_interfaces.py View 1 1 chunk +0 lines, -10 lines 0 comments Download
M charmworld/migrations/versions/020_adds_type_field_to_existing_review_items.py View 1 1 chunk +0 lines, -19 lines 0 comments Download
M charmworld/migrations/versions/021_drop_unproofed_bundles.py View 1 1 chunk +0 lines, -22 lines 0 comments Download
M charmworld/migrations/versions/022_Remove_all_QA_questions_and_data.py View 1 1 chunk +0 lines, -17 lines 0 comments Download
M charmworld/migrations/versions/023_insert_new_questions.py View 1 1 chunk +0 lines, -13 lines 0 comments Download
A charmworld/migrations/versions/024_create_charms_index.py View 1 1 chunk +7 lines, -0 lines 0 comments Download
M charmworld/migrations/versions/tests/test_migrations.py View 1 2 chunks +16 lines, -184 lines 0 comments Download
M charmworld/models.py View 4 chunks +4 lines, -2 lines 0 comments Download
M charmworld/testing/factory.py View 1 4 chunks +22 lines, -3 lines 0 comments Download
M charmworld/tests/test_models.py View 1 3 chunks +18 lines, -1 line 0 comments Download
M charmworld/views/helpers.py View 3 chunks +8 lines, -6 lines 0 comments Download

Messages

Total messages: 4
bac
Please take a look.
10 years, 2 months ago (2014-02-10 21:38:51 UTC) #1
j.c.sackett
https://codereview.appspot.com/61720043/diff/1/charmworld/migrations/migrate.py File charmworld/migrations/migrate.py (right): https://codereview.appspot.com/61720043/diff/1/charmworld/migrations/migrate.py#newcode33 charmworld/migrations/migrate.py:33: SCRIPT_TEMPLATE = '''\ The trailing slash here shouldn't be ...
10 years, 2 months ago (2014-02-10 22:28:57 UTC) #2
j.c.sackett
LGTM, with the concerns on deploy and minor quibbles above.
10 years, 2 months ago (2014-02-10 22:29:54 UTC) #3
bac
10 years, 2 months ago (2014-02-11 15:40:59 UTC) #4
Please take a look.

https://codereview.appspot.com/61720043/diff/1/charmworld/migrations/migrate.py
File charmworld/migrations/migrate.py (right):

https://codereview.appspot.com/61720043/diff/1/charmworld/migrations/migrate....
charmworld/migrations/migrate.py:33: SCRIPT_TEMPLATE = '''\
Without the backslash, the first line consists of just \n.  I used the backslash
to suppress the leading blank line.

https://codereview.appspot.com/61720043/diff/1/charmworld/migrations/migrate....
charmworld/migrations/migrate.py:57: '''
I added the commented out template just so future migrations would have the
required function name, signature, and documented parameters.  I can add more
explanation about when and why to use an update versus an exodus but I don't see
the harm in including it.  The fact it is commented out gives a hint to its
lesser importance relative to the update.

https://codereview.appspot.com/61720043/diff/1/charmworld/migrations/migrate....
charmworld/migrations/migrate.py:87: db.charms.create_index(
It does and using it allows me to get rid of the existence test.  Thanks.

https://codereview.appspot.com/61720043/diff/1/charmworld/migrations/migrate....
charmworld/migrations/migrate.py:192: setup_mongo_indices(datastore.db)
I think it is ideal to establish the index before data are loaded.  In that
instance the index is trivially updated as new data are added to the database.

The expensive maneuver is adding an index post-hoc and having mongo
retroactively calculate the index.

https://codereview.appspot.com/61720043/diff/1/charmworld/migrations/versions...
File charmworld/migrations/versions/024_create_charms_index.py (right):

https://codereview.appspot.com/61720043/diff/1/charmworld/migrations/versions...
charmworld/migrations/versions/024_create_charms_index.py:13:
setup_mongo_indices(db)
I've changed it to an exodus, so it can be long-running without locking up the
db.

https://codereview.appspot.com/61720043/diff/1/charmworld/testing/factory.py
File charmworld/testing/factory.py (right):

https://codereview.appspot.com/61720043/diff/1/charmworld/testing/factory.py#...
charmworld/testing/factory.py:323: """Make a bunch of charms.  Overwrite"""
On 2014/02/10 22:28:57, j.c.sackett wrote:
> Overwrite what?

Done.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b