Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added a command to upgrade schema to v2.

  • Loading branch information...
commit b56d9d491e219eee94a0057136284ffc94904a88 1 parent 1dcd2d8
@jacobian jacobian authored
Showing with 23 additions and 1 deletion.
  1. +4 −1 fabfile.py
  2. +19 −0 management/commands/upgrade_to_v2.py
View
5 fabfile.py
@@ -15,4 +15,7 @@ def deploy_code():
project.rsync_project(env.deployroot.parent, delete=True, exclude=['*.pyc'])
def update_deps():
- run('%s/bin/pip install -r %s/requirements.txt' % (env.venv, env.deployroot))
+ run('%s/bin/pip install -r %s/requirements.txt' % (env.venv, env.deployroot))
+
+def refresh_objects():
+ run('%s/bin/python %s/manage.py refresh_objects' % (env.venv, env.deployroot))
View
19 management/commands/upgrade_to_v2.py
@@ -0,0 +1,19 @@
+import redis
+import urllib
+import operator
+from django.conf import settings
+from django.core.management.base import NoArgsCommand
+from sphinx.ext import intersphinx
+
+r = redis.Redis(**settings.REDIS)
+
+class Command(NoArgsCommand):
+ def handle_noargs(self, **options):
+ v1_keys = r.keys('redirects:v1:*')
+ for k in v1_keys:
+ if r.type(k) == 'set':
+ term = k.rsplit(':')[-1]
+ for url in r.smembers(k):
+ score = r.get('redirects:v1:%s:%s' % (term, url))
+ r.sadd('redirects:v2:dev:%s' % (term,), url)
+ r.set('redirects:v2:dev:%s:%s' % (term, url), score)
Please sign in to comment.
Something went wrong with that request. Please try again.