forked from teammatehunt/puzzup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.py
137 lines (99 loc) · 2.92 KB
/
tasks.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import os
from invoke import task
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.dev")
HUNT_SLUG = "puzzup"
HEROKU_MANAGE = f"heroku run --app={HUNT_SLUG} python manage.py"
@task
def lint(c):
c.run("pylint --disable=R,C,W0511 $(git ls-files '*.py')")
@task
def pytype(c):
c.run("pytype $(git ls-files '*.py')")
@task
def run(c):
c.run("./manage.py runserver 4004")
@task
def export_users(c):
c.run(
"./manage.py dumpdata --format=yaml puzzle_editing.user --indent 4 > puzzle_editing/fixtures/auth.yaml"
)
@task
def export_users_from_prod(c):
c.run(
f"{HEROKU_MANAGE} dumpdata --format=yaml puzzle_editing.user --indent 4 > puzzle_editing/fixtures/auth.yaml"
)
@task
def export_prod(c):
c.run(
f"{HEROKU_MANAGE} dumpdata --format=yaml puzzle_editing --indent 4 > puzzle_editing/fixtures/data.yaml"
)
@task
def prod_shell(c):
c.run(f"{HEROKU_MANAGE} shell")
@task
def count_channels(c):
c.run(
f"{HEROKU_MANAGE} shell -c 'from puzzle_editing.discord_integration import get_client;c=get_client();print(len(c.get_channels_in_guild()))'"
)
@task
def migrate(c):
c.run("./manage.py migrate")
@task
def load_users(c):
c.run("./manage.py loaddata auth")
c.run("./manage.py loaddata groups")
@task
def load_data(c):
c.run("./manage.py loaddata auth")
c.run("./manage.py loaddata groups")
c.run("./manage.py loaddata puzzles")
@task
def regen(c):
"""
Rebuild database from seeds. This will *destroy* your local database, so use with caution.
"""
c.run(f"dropdb {HUNT_SLUG}")
c.run(f"createdb {HUNT_SLUG}")
migrate(c)
load_data(c)
@task
def shiva_the_destroyer(c):
"""
Redo all migrations and load data from seeds. This will *destroy* your local database, so use with caution.
"""
c.run(f"dropdb {HUNT_SLUG}")
c.run(f"createdb {HUNT_SLUG}")
c.run("rm -f puzzle_editing/migrations/*.py")
c.run("./manage.py makemigrations puzzle_editing")
migrate(c)
load_data(c)
@task
def push(c):
"""
Push to GitHub, which will automatically push to Heroku. Migration happens automatically.
"""
c.run("git push origin master")
@task
def load_prod(c):
"""
Load puzzle and text response data from fixtures on production.
"""
c.run(f"{HEROKU_MANAGE} loaddata puzzles")
@task
def load_all_prod(c):
"""
Load all data from fixtures on production.
"""
c.run(f"{HEROKU_MANAGE} loaddata auth")
c.run(f"{HEROKU_MANAGE} loaddata groups")
c.run(f"{HEROKU_MANAGE} loaddata puzzles")
# @task
# def regen_prod(c):
# """
# COMPLETELY DESTROY PROD DATABASE WITH NO RECOURSE! DON'T DO IT!
# """
# c.run(f"heroku pg:reset --app={HUNT_SLUG} --confirm={HUNT_SLUG}")
# c.run(f"{HEROKU_MANAGE} migrate")
# c.run(f"{HEROKU_MANAGE} loaddata auth")
# c.run(f"{HEROKU_MANAGE} loaddata groups")
# c.run(f"{HEROKU_MANAGE} loaddata puzzles")