Skip to content
Snippets Groups Projects
Commit b6361cb0 authored by Kevin S. Hahn's avatar Kevin S. Hahn
Browse files

rename remotes collection to sites for clarity

- the collection contains information about all sites, including local
  site, not just remote sites.
parent 16c4a656
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,7 @@ ap.add_argument('--db_uri', help='SciTran DB URI', required=True)
ap.add_argument('--data_path', help='path to storage area', required=True)
ap.add_argument('--ssl_cert', help='path to SSL certificate file, containing private key and certificate chain', required=True)
ap.add_argument('--api_uri', help='api uri, with https:// prefix')
ap.add_argument('--site_id', help='site ID for Scitran Central')
ap.add_argument('--site_id', help='site ID for Scitran Central [local]', default='local')
ap.add_argument('--site_name', help='site name')
ap.add_argument('--oauth2_id_endpoint', help='OAuth2 provider ID endpoint', default='https://www.googleapis.com/plus/v1/people/me/openIdConnect')
ap.add_argument('--demo', help='enable automatic user creation', action='store_true', default=False)
......
......@@ -51,8 +51,8 @@ def update(db, api_uri, site_name, site_id, ssl_cert, central_url):
for _id, remotes in response['users'].iteritems():
db.users.update({'_id': _id}, {'$set': {'remotes': remotes}})
if sites:
db.remotes.remove({'_id': {'$nin': [site['_id'] for site in response['sites']]}})
[db.remotes.update({'_id': site['_id']}, site, upsert=True) for site in sites]
db.sites.remove({'_id': {'$nin': [site['_id'] for site in response['sites']]}})
[db.sites.update({'_id': site['_id']}, site, upsert=True) for site in sites]
db.users.update( # clean users who no longer have remotes
{'remotes': {'$exists': True}, '_id': {'$nin': users.keys()}},
{'$unset': {'remotes': ''}},
......@@ -60,7 +60,7 @@ def update(db, api_uri, site_name, site_id, ssl_cert, central_url):
)
log.info('%3d users with remote data, %3d remotes' % (
len([u['_id'] for u in db.users.find({'remotes': {'$exists': True}}, {'_id': True})]),
len([s['_id'] for s in db.remotes.find({}, {'_id': True})])
len([s['_id'] for s in db.sites.find({}, {'_id': True})])
))
return True
else:
......@@ -76,9 +76,9 @@ def update(db, api_uri, site_name, site_id, ssl_cert, central_url):
def clean_remotes(db):
"""Remove db.remotes, and removes remotes field from all db.users."""
"""Remove db.sites, and removes remotes field from all db.users."""
log.debug('removing remotes from users, and remotes collection')
db.remotes.remove({})
db.sites.remove({})
db.users.update({'remotes': {'$exists': True}}, {'$unset': {'remotes': ''}}, multi=True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment