Skip to content

Commit

Permalink
Merge pull request #173 from pythonkr/devdev
Browse files Browse the repository at this point in the history
apply #171
  • Loading branch information
darjeeling authored Oct 1, 2024
2 parents 6447d76 + 91164b4 commit 6841f40
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 17 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/deploy_on_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10']
python-version: ["3.10"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
#- uses: psf/black@stable
# with:
# options: "--check --verbose"

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down Expand Up @@ -75,7 +75,6 @@ jobs:
sparse-checkout: |
${{ steps.info.outputs.repository_name }}/zappa_settings.json
- run: mv secret_envs/${{ steps.info.outputs.repository_name }}/zappa_settings.json ./zappa_settings.json && rm -rf secret_envs

# - name: Test with Django Test
# run: |
# source ./zappa-env/bin/activate
Expand All @@ -87,7 +86,7 @@ jobs:
# pytest .

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.PYCON_DEV_2023_AWS_KEY }}
aws-secret-access-key: ${{ secrets.PYCON_DEV_2023_AWS_SECRET }}
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/deploy_on_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10']
python-version: ["3.10"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
#- uses: psf/black@stable
# with:
# options: "--check --verbose"

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down Expand Up @@ -75,7 +75,6 @@ jobs:
sparse-checkout: |
${{ steps.info.outputs.repository_name }}/zappa_settings.json
- run: mv secret_envs/${{ steps.info.outputs.repository_name }}/zappa_settings.json ./zappa_settings.json && rm -rf secret_envs

# - name: Test with Django Test
# run: |
# source ./zappa-env/bin/activate
Expand All @@ -87,7 +86,7 @@ jobs:
# pytest .

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.PYCON_DEV_2023_AWS_KEY }}
aws-secret-access-key: ${{ secrets.PYCON_DEV_2023_AWS_SECRET }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull-request-merge-precondition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10']
python-version: ["3.10"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
persist-credentials: true # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
Expand Down
10 changes: 10 additions & 0 deletions pyconkr/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,16 @@
"PREPROCESSING_HOOKS": ["pyconkr.openapi.preprocessing_filter_spec"],
}


# cache for django localmem
# https://docs.djangoproject.com/en/5.1/topics/cache/#local-memory-caching
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
"LOCATION": "pyconkr-api-v2",
}
}

# CORS_ALLOW_ALL_ORIGINS = True
CORS_ORIGIN_WHITELIST = (
"https://2023.pycon.kr",
Expand Down
30 changes: 25 additions & 5 deletions session/viewsets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from django.conf import settings
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page
from drf_spectacular.utils import OpenApiExample, OpenApiResponse, extend_schema
from rest_framework.permissions import IsAuthenticatedOrReadOnly
from rest_framework.response import Response
Expand Down Expand Up @@ -28,14 +30,24 @@ def get_queryset(self):
200: OpenApiResponse(
response=str,
examples=[
OpenApiExample(name="2023년 세션 목록", value=SessionListSerializer(many=True)),
OpenApiExample(name="2024년 이후 세션 목록 (Pretalx)", value=PretalxSessionSerializer(many=True)),
OpenApiExample(
name="2023년 세션 목록", value=SessionListSerializer(many=True)
),
OpenApiExample(
name="2024년 이후 세션 목록 (Pretalx)",
value=PretalxSessionSerializer(many=True),
),
],
),
},
)
# cache list about 30 minutes
@method_decorator(cache_page(60 * 30))
def list(self, request, *args, **kwargs) -> Response:
if request.version == 2023 or request.version not in settings.PRETALX.EVENT_NAME:
if (
request.version == 2023
or request.version not in settings.PRETALX.EVENT_NAME
):
return super().list(request, *args, **kwargs)

pretalx_event_name = settings.PRETALX.EVENT_NAME[request.version]
Expand All @@ -52,13 +64,21 @@ def list(self, request, *args, **kwargs) -> Response:
response=str,
examples=[
OpenApiExample(name="2023년 세션 상세", value=SessionSerializer()),
OpenApiExample(name="2024년 이후 세션 상세 (Pretalx)", value=PretalxSessionSerializer()),
OpenApiExample(
name="2024년 이후 세션 상세 (Pretalx)",
value=PretalxSessionSerializer(),
),
],
),
},
)
# cache each about 30 minutes
@method_decorator(cache_page(60 * 30))
def retrieve(self, request, *args, **kwargs) -> Response:
if request.version == 2023 or request.version not in settings.PRETALX.EVENT_NAME:
if (
request.version == 2023
or request.version not in settings.PRETALX.EVENT_NAME
):
return super().retrieve(request, *args, **kwargs)

pretalx_event_name = settings.PRETALX.EVENT_NAME[request.version]
Expand Down

0 comments on commit 6841f40

Please sign in to comment.