-
Notifications
You must be signed in to change notification settings - Fork 11
/
manage
executable file
·39 lines (34 loc) · 1012 Bytes
/
manage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
from __future__ import print_function
import os, sys
abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
sys.path.insert(0, os.path.join(dname, "app"))
from flask.ext.script import Manager, Server, Shell
from app.github_contributions import app, mongo
def _make_context():
return dict(
app=app,
mongo=mongo
)
manager = Manager(app)
manager.add_command('shell', Shell(
make_context=_make_context,
use_ipython=True,
banner='GitHub Contributions Shell'
))
@manager.command
def ensure_indexes():
""" ensure contributions are indexed
"""
collection = mongo.db.contributions
print("indexing _event_id")
collection.create_index("_event_id",
sparse=True,
unique=True)
print("indexing _user_lower")
collection.create_index("_user_lower")
print("indexing created_at")
collection.create_index("created_at")
if __name__=='__main__':
manager.run()