Skip to content

Commit

Permalink
remove unnecessary util command
Browse files Browse the repository at this point in the history
  • Loading branch information
glass-ships committed Aug 8, 2024
1 parent ec17de2 commit 100df66
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 19 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ jobs:
channels: conda-forge,defaults
mamba-version: "*"
environment-file: environment.yml
# These don't seem to be valid options for this action
# See: https://github.com/conda-incubator/setup-miniconda
# cache-environment-key: ${{ runner.os }}-env-${{ hashFiles('**/environment.yml') }}
# cache-downloads-key: ${{ runner.os }}-downloads-${{ hashFiles('**/environment.yml') }}
cache-environment-key: ${{ runner.os }}-env-${{ hashFiles('**/environment.yml') }}
cache-downloads-key: ${{ runner.os }}-downloads-${{ hashFiles('**/environment.yml') }}

- name: Start docker containers
run: |
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ docker/compose/local: docker/compose/validate ## compose and start the service l
clean: ## remove all local compiled Python files
rm -f `find . -type f -name '*.py[co]' ` \
`find . -type f -name '_version.py'`
rm -rf `find . -name __pycache__` \
.ruff_cache .pytest_cache *.egg-info
rm -rf `find . -name __pycache__ -o -name "*.egg-info"` \
.ruff_cache .pytest_cache

.PHONY: check
.PHONY: first_install
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from django.core.management.base import BaseCommand
from django.utils import timezone

from ...view_util import purge_expired_runs
from ...models import DataRun


class Command(BaseCommand):
help = "Delete expired runs and related plots"

def handle(self, *args, **options): # noqa: ARG002
purge_expired_runs()
runs = DataRun.objects.all()
for run in runs:
if run.expiration_date < timezone.now():
run.delete()
10 changes: 0 additions & 10 deletions src/live_data_server/plots/view_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,3 @@ def store_plot_data(instrument, run_id, data, data_type, expiration_date: dateti
plot_data.data_type = data_type
plot_data.timestamp = timezone.now()
plot_data.save()


def purge_expired_runs():
"""
Purge expired runs and related plots
"""
runs = DataRun.objects.all()
for run in runs:
if run.expiration_date < timezone.now():
run.delete()
2 changes: 1 addition & 1 deletion tests/test_expiration.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_expiration_user(self, data_server):
assert r[1]["expired"] is True

def test_deleting_expired(self):
"""Test the purge_expired view"""
"""Test the purge_expired_data command"""
command = "docker exec -i live_data_server-livedata-1 bash -ic"
subcommand = "conda activate livedata && cd app && python manage.py purge_expired_data"
output = subprocess.check_output([*command.split(" "), subcommand])
Expand Down

0 comments on commit 100df66

Please sign in to comment.