Skip to content

Commit

Permalink
fix compose analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
verkalacheva committed Jun 20, 2024
1 parent 4a9abbd commit 9053383
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 32 deletions.
Empty file removed __init__.py
Empty file.
7 changes: 3 additions & 4 deletions analytics/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ WORKDIR /app

RUN pip install gunicorn==20.1.0

COPY requirements.txt ./
COPY analytics/requirements.txt .

RUN pip install -r requirements.txt --no-cache-dir

COPY . /app/
COPY . .
COPY ./analytics .

CMD ["gunicorn", "--bind", "0.0.0.0:9500", "QuizPlatform.wsgi"]
CMD ["gunicorn", "--bind", "0.0.0.0:9500", "project.wsgi"]
Empty file removed analytics/__init__.py
Empty file.
1 change: 1 addition & 0 deletions analytics/project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
'drf_spectacular',
'corsheaders',
'analytics',
'tests'
]

MIDDLEWARE = [
Expand Down
18 changes: 8 additions & 10 deletions compose/docker-compose-DH-DEV.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
version: '3.3'
volumes:
tests_data:
static:
static_django_analytics:
name: compose-dev

services:
client:
image: ishutachkaa/frontend:DEV
volumes:
- static_django_analytics:/client/build/
- static:/client/build/

api: &api
image: ishutachkaa/backend-subjects:DEV
Expand All @@ -19,7 +17,7 @@ services:
volumes:
- ../dbs/subjects_db.sqlite3:/app/db.sqlite3
- ./startscripts/cmd.subjects.sh:/app/cmd.subjects.sh
- static_django_analytics:/app/static_django_analytics/
- static:/app/static/
restart: unless-stopped
depends_on:
- client
Expand All @@ -32,7 +30,7 @@ services:
volumes:
- ../dbs/users_db.sqlite3:/app/db.sqlite3
- ./startscripts/cmd.users.sh:/app/cmd.users.sh
- static_django_analytics:/app/static_django_analytics/
- static:/app/static/
depends_on:
- client
restart: unless-stopped
Expand All @@ -44,9 +42,8 @@ services:
command: ./cmd.tests.sh
volumes:
- ../dbs/tests_db.sqlite3:/app/db.sqlite3
- tests_data:/app/tests
- ./startscripts/cmd.tests.sh:/app/cmd.tests.sh
- static_django_analytics:/app/static_django_analytics/
- static:/app/static/
depends_on:
- client
restart: unless-stopped
Expand All @@ -58,10 +55,11 @@ services:
command: ./cmd.analytics.sh
volumes:
- ../dbs/analytics_db.sqlite3:/app/db.sqlite3
- tests_data:/app/tests
- ./startscripts/cmd.analytics.sh:/app/cmd.analytics.sh
- static_django_analytics:/app/static_django_analytics/
- static:/app/static/
- ../tests:/app/tests/models
depends_on:
- client
- tests
restart: unless-stopped

Expand All @@ -71,7 +69,7 @@ services:
- 9999:80
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
- static_django_analytics:/usr/share/nginx/html/
- static:/usr/share/nginx/html/
restart: unless-stopped
depends_on:
- client
Expand Down
33 changes: 16 additions & 17 deletions compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
version: '3.3'

volumes:
static_django_analytics:
tests_data:

static:
services:
client:
build:
context: ../
dockerfile: client/Dockerfile
volumes:
- static_django_analytics:/client/build/

api:
- static:/client/build/
api: &api
build:
context: ../subjects
dockerfile: docker/dev/Dockerfile
Expand All @@ -22,7 +19,7 @@ services:
volumes:
- ../dbs/subjects_db.sqlite3:/app/db.sqlite3
- ./startscripts/cmd.subjects.sh:/app/cmd.subjects.sh
- static_django_analytics:/app/static_django_analytics/
- static:/app/static/
restart: unless-stopped
depends_on:
- client
Expand All @@ -35,7 +32,7 @@ services:
volumes:
- ../dbs/users_db.sqlite3:/app/db.sqlite3
- ./startscripts/cmd.users.sh:/app/cmd.users.sh
- static_django_analytics:/app/static_django_analytics/
- static:/app/static/
depends_on:
- client
restart: unless-stopped
Expand All @@ -48,39 +45,41 @@ services:
volumes:
- ../dbs/tests_db.sqlite3:/app/db.sqlite3
- ./startscripts/cmd.tests.sh:/app/cmd.tests.sh
- tests_data:/app/tests
- static_django_analytics:/app/static_django_analytics/
- static:/app/static/
depends_on:
- client
restart: unless-stopped

analytics:
build: ../analytics/
build:
context: ../
dockerfile: analytics/Dockerfile
env_file:
- ./env/.env.analytics
command: ./cmd.analytics.sh
volumes:
- ../dbs/analytics_db.sqlite3:/app/db.sqlite3
- ./startscripts/cmd.analytics.sh:/app/cmd.analytics.sh
- tests_data:/app/tests
- static_django_analytics:/app/static_django_analytics/
- static:/app/static/
- ../tests:/app/tests/models
depends_on:
- client
- tests
restart: unless-stopped



gateway:
image: nginx
ports:
- 8888:80
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
- static_django_analytics:/usr/share/nginx/html/
- static:/usr/share/nginx/html/

restart: unless-stopped
depends_on:
- client
- users
- tests
- api
- analytics
- analytics
Empty file removed tests/__init__.py
Empty file.
21 changes: 20 additions & 1 deletion tests/tests/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.db import models


class Test(models.Model):
author_id = models.IntegerField(null=False, blank=False)
subject_id = models.IntegerField(null=False, blank=False)
Expand All @@ -8,26 +9,44 @@ class Test(models.Model):
expert_id = models.IntegerField(default=0, null=False, blank=False)
max_points = models.IntegerField(default=0, null=False, blank=False)

class Meta:
app_label = 'tests'


class Question(models.Model):
id_test = models.ForeignKey(Test, on_delete=models.CASCADE, related_name='questions')
question_text = models.CharField(max_length=100, null=False, blank=False)
addition_info = models.TextField(null=False, blank=False)
question_points = models.IntegerField(default=0, null=False, blank=False)

class Meta:
app_label = 'tests'


class Answer(models.Model):
answer_text = models.TextField(null=False, blank=False)
id_question = models.ForeignKey(Question, on_delete=models.CASCADE, related_name='answers')
is_correct = models.BooleanField()

class Meta:
app_label = 'tests'


class Result(models.Model):
id_user = models.IntegerField(null=False, blank=False)
id_test = models.ForeignKey(Test, on_delete=models.CASCADE)
subject = models.TextField(null=False, blank=False)
theme = models.TextField(null=False, blank=False)
points_user = models.IntegerField(null=True, blank=False)

class Meta:
app_label = 'tests'


class Solutions(models.Model):
id_result = models.ForeignKey(Result, on_delete=models.CASCADE, related_name='solutions')
id_question = models.ForeignKey(Question, on_delete=models.CASCADE)
user_answer = models.TextField(null=False, blank=False)
user_answer = models.TextField(null=False, blank=False)

class Meta:
app_label = 'tests'

0 comments on commit 9053383

Please sign in to comment.