Skip to content

Commit

Permalink
Changed command to hide Hide-Matches to Show matches
Browse files Browse the repository at this point in the history
  • Loading branch information
krugergui committed Oct 25, 2023
1 parent 84a429c commit dd4fe47
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 10 deletions.
19 changes: 13 additions & 6 deletions backend/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,16 @@ class Meta:
many = True

def validate(self, data):
print(
[
data["soft_skill_test_matching"][i].soft_skill_name
for i in data["soft_skill_test_matching"]
]
)
print(data["about_me"])
return data

def get_matches(self, instance):
headers = self.context["request"].headers
print(headers)
if "Hide-Matches" in headers:
if headers["Hide-Matches"] == "true":
return "Hide-Matches set to true"

HARD_SKILL_PERCENTAGE = float(os.environ["HARD_SKILL_PERCENTAGE"])
SOFT_SKILL_PERCENTAGE = float(os.environ["SOFT_SKILL_PERCENTAGE"])
FREE_TEXT_PERCENTAGE = float(os.environ["FREE_TEXT_PERCENTAGE"])
Expand Down Expand Up @@ -243,6 +244,12 @@ class Meta:
many = True

def get_matches(self, instance):
headers = self.context["request"].headers
print(headers)
if "Hide-Matches" in headers:
if headers["Hide-Matches"] == "true":
return "Hide-Matches set to true"

HARD_SKILL_PERCENTAGE = float(os.environ["HARD_SKILL_PERCENTAGE"])
SOFT_SKILL_PERCENTAGE = float(os.environ["SOFT_SKILL_PERCENTAGE"])
FREE_TEXT_PERCENTAGE = float(os.environ["FREE_TEXT_PERCENTAGE"])
Expand Down
36 changes: 32 additions & 4 deletions backend/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework import mixins
from drf_spectacular.utils import (
extend_schema_view,
extend_schema,
)
from drf_spectacular.utils import extend_schema_view, extend_schema, OpenApiParameter

import json
from api import serializers as model_serializers
Expand Down Expand Up @@ -290,6 +287,21 @@ def post(self, request):
return Response(response_payload, status=status_code)


@extend_schema_view(
retrieve=extend_schema(
summary="Retrieve information for a candidate",
description="""
Provide the candidate id in the url parameter and this will retrieve all the information associated with the candidate.
Optional:
Hide-Matches: bool
If true, will not return the matches for faster loading
""",
parameters=[
OpenApiParameter("Hide-Matches", bool, OpenApiParameter.HEADER),
],
),
)
class CandidatesViewSet(viewsets.ModelViewSet):
queryset = model_serializers.Candidates.objects.all()
serializer_class = model_serializers.CandidatesSerializer
Expand All @@ -300,6 +312,22 @@ class AvailableCompanyDomainsViewSet(viewsets.ModelViewSet):
serializer_class = model_serializers.AvailableCompanyDomainsSerializer


@extend_schema_view(
retrieve=extend_schema(
summary="Retrieve information for a job",
description="""
Provide the job id in the url parameter and this will retrieve all the information associated with the job.
Optional:
Hide-Matches: bool
If true, will not return the matches for faster loading
""",
parameters=[
OpenApiParameter("job_id", int, OpenApiParameter.PATH, required=True),
OpenApiParameter("Hide-Matches", bool, OpenApiParameter.HEADER),
],
),
)
class JobsViewSet(viewsets.ModelViewSet):
queryset = model_serializers.Jobs.objects.all()
serializer_class = model_serializers.JobsSerializer
Expand Down

0 comments on commit dd4fe47

Please sign in to comment.