-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'prod' of https://github.com/ristekoss/ulaskelas-backend …
…into fix/disparity
- Loading branch information
Showing
27 changed files
with
611 additions
and
43 deletions.
There are no files selected for viewing
42 changes: 21 additions & 21 deletions
42
.ebextensions/django.config → .ebextensions/02_django.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
option_settings: | ||
aws:elasticbeanstalk:application:environment: | ||
DJANGO_SETTINGS_MODULE: "UlasKelas.settings" | ||
POSTGRES_DB: "" | ||
POSTGRES_USER: "" | ||
POSTGRES_PASSWORD: "" | ||
POSTGRES_HOST: "" | ||
SENTRY_DSN: "" | ||
aws:elasticbeanstalk:container:python: | ||
WSGIPath: "UlasKelas.wsgi:application" | ||
aws:elasticbeanstalk:environment:proxy:staticfiles: | ||
/static: static | ||
aws:elasticbeanstalk:environment:process:default: | ||
HealthCheckPath: "/ping" | ||
MatcherHTTPCode: "200-499" | ||
commands: | ||
01_postgres_activate: | ||
command: sudo amazon-linux-extras enable postgresql11 | ||
02_postgres_install: | ||
command: sudo yum install -y postgresql-devel | ||
option_settings: | ||
aws:elasticbeanstalk:application:environment: | ||
DJANGO_SETTINGS_MODULE: "UlasKelas.settings" | ||
POSTGRES_DB: "" | ||
POSTGRES_USER: "" | ||
POSTGRES_PASSWORD: "" | ||
POSTGRES_HOST: "" | ||
SENTRY_DSN: "" | ||
aws:elasticbeanstalk:container:python: | ||
WSGIPath: "UlasKelas.wsgi:application" | ||
aws:elasticbeanstalk:environment:proxy:staticfiles: | ||
/static: static | ||
aws:elasticbeanstalk:environment:process:default: | ||
HealthCheckPath: "/ping" | ||
MatcherHTTPCode: "200-499" | ||
|
||
commands: | ||
01_postgres_activate: | ||
command: sudo amazon-linux-extras enable postgresql11 | ||
02_postgres_install: | ||
command: sudo yum install -y postgresql-devel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
container_commands: | ||
01setup_swap: | ||
command: "sudo bash .ebextensions/setup_swap.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
SWAPFILE=/var/swapfile | ||
SWAP_MEGABYTES=768 | ||
|
||
if [ -f $SWAPFILE ]; then | ||
echo "Swapfile $SWAPFILE found, assuming already setup" | ||
exit; | ||
fi | ||
|
||
/bin/dd if=/dev/zero of=$SWAPFILE bs=1M count=$SWAP_MEGABYTES | ||
/bin/chmod 600 $SWAPFILE | ||
/sbin/mkswap $SWAPFILE | ||
/sbin/swapon $SWAPFILE | ||
sysctl vm.swappiness=15 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
release: bash deployment.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
release: bash deployment.sh | ||
web: gunicorn UlasKelas.wsgi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from datetime import datetime | ||
from django.db import transaction | ||
from django.db.models import Count, Sum | ||
from apscheduler.schedulers.background import BackgroundScheduler | ||
from apscheduler.triggers.interval import IntervalTrigger | ||
|
||
from main.models import Profile, Review | ||
|
||
def update_leaderboard(): | ||
users = Profile.objects.all() | ||
|
||
for user in users: | ||
likes_count = Review.objects.filter(user=user).filter(is_active=True).annotate(likes_count=Count('reviewlike')).aggregate(Sum('likes_count'))['likes_count__sum'] | ||
user.likes_count = likes_count | ||
|
||
with transaction.atomic(): | ||
for user in users: | ||
user.save() | ||
|
||
def start(): | ||
scheduler = BackgroundScheduler() | ||
scheduler.add_job( | ||
update_leaderboard, | ||
trigger=IntervalTrigger(minutes=5), # Every 5 minutes | ||
id="update_courses", | ||
max_instances=1, | ||
replace_existing=True, | ||
) | ||
scheduler.start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.1.2 on 2022-07-22 12:12 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('main', '0002_profile_is_blocked'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='review', | ||
name='is_reviewed', | ||
field=models.BooleanField(default=False), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Generated by Django 3.1.2 on 2022-07-28 07:25 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('main', '0003_review_is_reviewed'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Calculator', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('total_score', models.FloatField(default=0)), | ||
('total_percentage', models.FloatField(default=0)), | ||
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='main.course')), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='main.profile')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='ScoreComponent', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.TextField()), | ||
('weight', models.FloatField()), | ||
('score', models.FloatField()), | ||
('calculator', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='main.calculator')), | ||
], | ||
), | ||
] |
43 changes: 43 additions & 0 deletions
43
main/migrations/0005_profile_likes_count_review_rating_beneficial_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Generated by Django 4.0.6 on 2022-07-30 03:56 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('main', '0004_calculator_scorecomponent'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='profile', | ||
name='likes_count', | ||
field=models.PositiveIntegerField(default=0), | ||
), | ||
migrations.AddField( | ||
model_name='review', | ||
name='rating_beneficial', | ||
field=models.PositiveSmallIntegerField(default=0), | ||
), | ||
migrations.AddField( | ||
model_name='review', | ||
name='rating_fit_to_credit', | ||
field=models.PositiveSmallIntegerField(default=0), | ||
), | ||
migrations.AddField( | ||
model_name='review', | ||
name='rating_fit_to_study_book', | ||
field=models.PositiveSmallIntegerField(default=0), | ||
), | ||
migrations.AddField( | ||
model_name='review', | ||
name='rating_recommended', | ||
field=models.PositiveSmallIntegerField(default=0), | ||
), | ||
migrations.AddField( | ||
model_name='review', | ||
name='rating_understandable', | ||
field=models.PositiveSmallIntegerField(default=0), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.0.6 on 2022-07-30 06:00 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('main', '0005_profile_likes_count_review_rating_beneficial_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='profile', | ||
name='likes_count', | ||
field=models.PositiveIntegerField(default=0, null=True), | ||
), | ||
] |
38 changes: 38 additions & 0 deletions
38
main/migrations/0007_alter_review_rating_beneficial_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Generated by Django 4.0.6 on 2022-07-30 07:52 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('main', '0006_alter_profile_likes_count'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='review', | ||
name='rating_beneficial', | ||
field=models.FloatField(default=0, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='review', | ||
name='rating_fit_to_credit', | ||
field=models.FloatField(default=0, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='review', | ||
name='rating_fit_to_study_book', | ||
field=models.FloatField(default=0, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='review', | ||
name='rating_recommended', | ||
field=models.FloatField(default=0, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='review', | ||
name='rating_understandable', | ||
field=models.FloatField(default=0, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.