Skip to content
This repository was archived by the owner on Mar 27, 2023. It is now read-only.

Commit b35fbae

Browse files
committed
resolved merge conflicts
2 parents aeb7182 + 6ecf1a3 commit b35fbae

File tree

18 files changed

+146
-116
lines changed

18 files changed

+146
-116
lines changed

backend/.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
data/*
2+
static/*
3+
backup.json
4+
media/*
5+
notebooks/*
6+
.pytest_cache/

backend/apps/accounts/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from django.urls import include, path, re_path
1+
from django.urls import include, path
22

33
from . import views
44

backend/apps/banking/tasks.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
from io import StringIO
44

55
import celery
6-
from celery.task import task
76

87
from apps.banking.models import StatementFile, Transaction
98

9+
from backend.celery_app import app
10+
1011

1112
class BaseTask(celery.Task):
1213
pass
1314

1415

15-
@task(bind=True, base=BaseTask)
16+
@app.task(bind=True, base=BaseTask)
1617
def process_statement_file(self, statement_file_id):
1718

1819
"""

backend/apps/core/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# https://developers.google.com/identity/protocols/OpenIDConnect
33

44
OAUTH = {
5-
"github": {"name": "github", "url": "https://github.com/login/oauth/access_token",},
5+
"github": {"name": "github", "url": "https://github.com/login/oauth/access_token"},
66
"google-oauth2": {
77
"name": "google-oauth2",
88
"url": "https://oauth2.googleapis.com/token",

backend/apps/core/management/commands/watch_celery_beat.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

backend/apps/core/management/commands/watch_daphne.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

backend/apps/core/routing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@
33
from . import consumers
44

55
websocket_urlpatterns = [
6-
url(r"^ws/ping-pong/$", consumers.CoreConsumer),
7-
# url(r'^ws/chat/(?P<room_name>[^/]+)/$', consumers.CoreConsumer),
6+
url(r"^ws/ping-pong/$", consumers.CoreConsumer.as_asgi(),),
87
]

backend/apps/core/tasks.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
import time
22

33
import celery
4-
from celery.decorators import periodic_task
5-
from celery.task import task
6-
from celery.task.schedules import crontab
74
from django.core.mail import send_mail
85

6+
from backend.celery_app import app
7+
98

109
# http://docs.celeryproject.org/en/latest/userguide/tasks.html#task-inheritance
1110
class BaseTask(celery.Task):
1211
pass
1312

1413

15-
@task(bind=True, base=BaseTask)
14+
@app.task(bind=True, base=BaseTask)
1615
def debug_task(self):
1716
time.sleep(10)
1817

1918

20-
@periodic_task(
21-
run_every=(crontab(minute="*/1")), name="debug_periodic_task", ignore_result=True,
22-
)
23-
def debug_periodic_task():
19+
@app.task(bind=True, base=BaseTask)
20+
def debug_periodic_task(self):
2421
print("Periodic task complete")
2522

2623

27-
@task(bind=True, base=BaseTask)
24+
@app.task(bind=True, base=BaseTask)
2825
def send_test_email_task(self):
2926
send_mail(
3027
"Email subject",
@@ -35,7 +32,7 @@ def send_test_email_task(self):
3532
)
3633

3734

38-
@task(bind=True, base=BaseTask)
35+
@app.task(bind=True, base=BaseTask)
3936
def sleep_task(self, seconds):
4037
time.sleep(int(seconds))
4138
return f"Slept {seconds} seconds"

backend/backend/routing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
from channels.auth import AuthMiddlewareStack
22
from channels.routing import ProtocolTypeRouter, URLRouter
3+
from django.core.asgi import get_asgi_application
34

45
import apps.core.routing
56

67
application = ProtocolTypeRouter(
78
{
89
# Empty for now (http->django views is added by default)
10+
"http": get_asgi_application(),
911
"websocket": AuthMiddlewareStack(
1012
URLRouter(apps.core.routing.websocket_urlpatterns)
1113
),

backend/backend/settings/base.py

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import os
1414

15-
from kombu import Queue
15+
from kombu import Exchange, Queue
1616
import redis
1717

1818
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
@@ -167,15 +167,30 @@
167167

168168
# Channels
169169

170+
CACHES = {
171+
"default": {
172+
"BACKEND": "django_redis.cache.RedisCache",
173+
"LOCATION": f"redis://{REDIS_SERVICE_HOST}:6379/4",
174+
"OPTIONS": {"CLIENT_CLASS": "django_redis.client.DefaultClient"},
175+
"KEY_PREFIX": "djangoredis",
176+
}
177+
}
178+
170179
CHANNEL_LAYERS = {
171180
"default": {
172181
"BACKEND": "channels_redis.core.RedisChannelLayer",
173-
"CONFIG": {"hosts": [(REDIS_SERVICE_HOST, 6379)],}, # noqa
182+
"CONFIG": {
183+
"hosts": [(REDIS_SERVICE_HOST, 6379)],
184+
}, # noqa
174185
},
175186
}
176187

177188
REDIS = redis.Redis(
178-
host=REDIS_SERVICE_HOST, port=6379, db=3, charset="utf-8", decode_responses=True,
189+
host=REDIS_SERVICE_HOST,
190+
port=6379,
191+
db=3,
192+
charset="utf-8",
193+
decode_responses=True,
179194
)
180195

181196
# REST FRAMEWORK
@@ -190,15 +205,41 @@
190205
}
191206

192207
# Celery Configuration
208+
CELERY_QUEUE_DEFAULT = "default"
209+
CELERY_QUEUE_OTHER = "other"
210+
211+
CELERY_BROKER_URL = f"redis://{REDIS_SERVICE_HOST}:6379/1" # noqa
212+
CELERY_RESULT_BACKEND = f"redis://{REDIS_SERVICE_HOST}:6379/2" # noqa
193213
CELERY_ACCEPT_CONTENT = ["application/json"]
194214
CELERY_TASK_SERIALIZER = "json"
195215
CELERY_RESULT_SERIALIZER = "json"
196-
CELERY_BROKER_URL = f"redis://{REDIS_SERVICE_HOST}:6379/1" # noqa
197-
CELERY_RESULT_BACKEND = f"redis://{REDIS_SERVICE_HOST}:6379/2" # noqa
198216

199217
CELERY_QUEUE_DEFAULT = "default"
200218

201-
CELERY_QUEUES = (Queue(CELERY_QUEUE_DEFAULT, routing_key="default"),)
219+
CELERY_QUEUES = (
220+
Queue(
221+
CELERY_QUEUE_DEFAULT,
222+
Exchange(CELERY_QUEUE_DEFAULT),
223+
routing_key=CELERY_QUEUE_DEFAULT,
224+
),
225+
Queue(
226+
CELERY_QUEUE_OTHER,
227+
Exchange(CELERY_QUEUE_OTHER),
228+
routing_key=CELERY_QUEUE_OTHER,
229+
),
230+
)
231+
232+
CELERY_DEFAULT_EXCHANGE_TYPE = "direct"
233+
CELERY_TASK_DEFAULT_QUEUE = CELERY_QUEUE_DEFAULT
234+
CELERY_TASK_DEFAULT_EXCHANGE = CELERY_QUEUE_DEFAULT
235+
CELERY_TASK_DEFAULT_ROUTING_KEY = CELERY_QUEUE_DEFAULT
236+
237+
CELERY_BEAT_SCHEDULE = {
238+
"debug-periodic": {
239+
"task": "apps.core.tasks.debug_periodic_task",
240+
"schedule": 30, # scrape suppliers once every 5 minutes
241+
},
242+
}
202243

203244

204245
AUTH_USER_MODEL = "accounts.CustomUser"
@@ -210,7 +251,9 @@
210251
{
211252
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", # noqa
212253
},
213-
{"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",}, # noqa
254+
{
255+
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
256+
}, # noqa
214257
{
215258
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", # noqa
216259
},

0 commit comments

Comments
 (0)