From e5941ff824548328b2919937a35d5a51bb4a9984 Mon Sep 17 00:00:00 2001 From: Brandon Zhu Date: Tue, 18 Jun 2024 15:19:17 -0400 Subject: [PATCH] Fixed whitespace --- .github/workflows/test_django_api.yaml | 41 ------------------- .github/workflows/test_evagram_api.yaml | 6 +++ pycodestyle.cfg | 2 +- .../website/backend/api/serializers.py | 1 - src/evagram/website/backend/api/views.py | 26 +++++++----- 5 files changed, 23 insertions(+), 53 deletions(-) delete mode 100644 .github/workflows/test_django_api.yaml diff --git a/.github/workflows/test_django_api.yaml b/.github/workflows/test_django_api.yaml deleted file mode 100644 index db407da..0000000 --- a/.github/workflows/test_django_api.yaml +++ /dev/null @@ -1,41 +0,0 @@ -name: Test Database Tool -on: - pull_request: - types: - - opened - - synchronize - - reopened - -jobs: - build: - runs-on: ubuntu-latest - - services: - postgres: - image: postgres:latest - env: - POSTGRES_DB: ${{secrets.DB_NAME}} - POSTGRES_USER: ${{secrets.DB_USER}} - POSTGRES_PASSWORD: ${{secrets.DB_PASSWORD}} - ports: - - 5432:5432 - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 - - steps: - - name: Checkout Repository - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.x - - - name: Install Dependencies - run: | - python -m pip install --upgrade pip - pip install . -r requirements.txt - - - name: Run Django Model Tests - env: - DB_PASSWORD: ${{secrets.DB_PASSWORD}} - run: python ./src/evagram/website/backend/manage.py test api diff --git a/.github/workflows/test_evagram_api.yaml b/.github/workflows/test_evagram_api.yaml index 2c7831a..af17e79 100644 --- a/.github/workflows/test_evagram_api.yaml +++ b/.github/workflows/test_evagram_api.yaml @@ -33,6 +33,12 @@ jobs: python -m pip install --upgrade pip pip install . -r requirements.txt + - name: Create PGPASS File + run: | + echo 127.0.0.1:5432:test_evagram:postgres:${{secrets.DB_PASSWORD}} >> ~/.pgpass + chmod 600 ~/.pgpass + export PGPASSFILE='/home/runner/.pgpass' + - name: Run Django API Tests run: python src/evagram/website/backend/manage.py test api env: diff --git a/pycodestyle.cfg b/pycodestyle.cfg index db4875f..c874899 100644 --- a/pycodestyle.cfg +++ b/pycodestyle.cfg @@ -9,4 +9,4 @@ max-line-length = 100 indent-size = 4 statistics = True ignore = W503, W504 -exclude = __pycache__, src/evagram/website/backend/api/migrations +exclude = __pycache__, src/evagram/website/backend/api/migrations, src/evagram/website/frontend/node_modules diff --git a/src/evagram/website/backend/api/serializers.py b/src/evagram/website/backend/api/serializers.py index a44a6b8..2dccf7c 100644 --- a/src/evagram/website/backend/api/serializers.py +++ b/src/evagram/website/backend/api/serializers.py @@ -3,7 +3,6 @@ from django.db import models - class OwnerSerializer(serializers.ModelSerializer): key = serializers.ModelField(model_field=Owners()._meta.get_field('owner_id')) value = serializers.ModelField(model_field=Owners()._meta.get_field('owner_id')) diff --git a/src/evagram/website/backend/api/views.py b/src/evagram/website/backend/api/views.py index 4df0e77..1c2f8e7 100644 --- a/src/evagram/website/backend/api/views.py +++ b/src/evagram/website/backend/api/views.py @@ -30,6 +30,7 @@ def initial_load(request): data["groups"] = get_groups_by_variable(first_variable) return Response(data) + @api_view(['GET']) def get_plots_by_field(request): try: @@ -65,18 +66,20 @@ def get_plots_by_field(request): # lookup variable id by variable name and channel if channel == "null": channel = None - variable_id = Variables.objects.get(variable_name=variable_name, channel=channel).variable_id - plots = Plots.objects.filter(experiment_id=experiment_id, observation_id=observation_id, variable_id=variable_id) - + variable_id = Variables.objects.get( + variable_name=variable_name, channel=channel).variable_id + plots = Plots.objects.filter( + experiment_id=experiment_id, observation_id=observation_id, variable_id=variable_id) + elif group_id != "": if channel == "null": channel = None variable_id = Variables.objects.get(variable_name=variable_name, channel=channel) plots = Plots.objects.filter(experiment=experiment_id, - group=group_id, - observation=observation_id, - variable_id=variable_id) - + group=group_id, + observation=observation_id, + variable_id=variable_id) + serializer = PlotSerializer(plots, many=True) return Response(serializer.data) @@ -90,6 +93,7 @@ def get_plots_by_field(request): except ObjectDoesNotExist as e: return Response({"error": str(e)}, status=400) + @api_view(['GET']) def update_user_option(request): try: @@ -165,7 +169,8 @@ def update_observation_option(request): data["variables"] = get_variables_by_observation(observation_id) variablesMap = {} for variable in data["variables"]: - variablesMap[variable['variable_name']] = variablesMap.get(variable['variable_name'], []) + [variable['channel']] + variablesMap[variable['variable_name']] = variablesMap.get( + variable['variable_name'], []) + [variable['channel']] data["variablesMap"] = variablesMap if len(data["variables"]) > 0: data["groups"] = get_groups_by_variable(data["variables"][0]["variable_id"]) @@ -190,7 +195,7 @@ def update_variable_option(request): variable_id = None if channel == "null": - # check if variable does not include a channel by default, + # check if variable does not include a channel by default, # otherwise it has not been configured yet in the PlotMenu queryset = Variables.objects.filter(variable_name=variable_name, channel=None) if len(queryset) == 1: @@ -203,7 +208,8 @@ def update_variable_option(request): variable_id = queryset[0].variable_id # get variable id from variable name and channel else: - variable_id = Variables.objects.get(variable_name=variable_name, channel=channel).variable_id + variable_id = Variables.objects.get( + variable_name=variable_name, channel=channel).variable_id data = { "groups": [],