Skip to content

Commit

Permalink
Fixed whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonzhu09 committed Jun 18, 2024
1 parent d15ab27 commit e5941ff
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 53 deletions.
41 changes: 0 additions & 41 deletions .github/workflows/test_django_api.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions .github/workflows/test_evagram_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pycodestyle.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion src/evagram/website/backend/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down
26 changes: 16 additions & 10 deletions src/evagram/website/backend/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand All @@ -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:
Expand Down Expand Up @@ -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"])
Expand All @@ -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:
Expand All @@ -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": [],
Expand Down

0 comments on commit e5941ff

Please sign in to comment.