Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add environment variable CABOT_RESULTS_RETENTION_DAYS #669

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions cabot/cabotapp/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@ def clean_db(days_to_retain=7, batch_size=10000):
InstanceStatusSnapshot.objects.filter(id__in=instance_snapshot_ids).delete()

# If we reached the batch size on either we need to re-queue to continue cleaning up.
if (
result_count == batch_size or
service_snapshot_count == batch_size or
instance_snapshot_count == batch_size
):
if result_count == batch_size or service_snapshot_count == batch_size or instance_snapshot_count == batch_size:
thomasleveil marked this conversation as resolved.
Show resolved Hide resolved
clean_db.apply_async(kwargs={
'days_to_retain': days_to_retain,
'batch_size': batch_size},
Expand Down
2 changes: 1 addition & 1 deletion cabot/cabotapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class Meta:
}),
'text_match': forms.TextInput(attrs={
'style': 'width: 100%',
'placeholder': '[Aa]rachnys\s+[Rr]ules',
'placeholder': r'[Aa]rachnys\s+[Rr]ules',
}),
'status_code': forms.TextInput(attrs={
'style': 'width: 20%',
Expand Down
3 changes: 3 additions & 0 deletions cabot/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
},
'clean-db': {
'task': 'cabot.cabotapp.tasks.clean_db',
'kwargs': {
'days_to_retain': os.environ.get('CABOT_RESULTS_RETENTION_DAYS', 7)
},
'schedule': timedelta(seconds=60 * 60 * 24),
},
}
2 changes: 1 addition & 1 deletion cabot/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
COMPRESS_PRECOMPILERS = (
('text/coffeescript', 'coffee --compile --stdio'),
('text/eco',
'eco -i TEMPLATES {infile} && cat "$(echo "{infile}" | sed -e "s/\.eco$/.js/g")"'),
r'eco -i TEMPLATES {infile} && cat "$(echo "{infile}" | sed -e "s/\.eco$/.js/g")"'),
('text/less', 'lessc {infile} > {outfile}'),
)

Expand Down
2 changes: 2 additions & 0 deletions conf/default.env
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ DJANGO_SETTINGS_MODULE=cabot.settings
LOG_FILE=/dev/null
PORT=5001

CABOT_RESULTS_RETENTION_DAYS=7

# You shouldn't need to change anything above this line

# Base path to include before generated URLs. If not defined, uses `/`
Expand Down
2 changes: 2 additions & 0 deletions conf/development.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ DJANGO_SETTINGS_MODULE=cabot.settings
LOG_FILE=/dev/null
PORT=5001

CABOT_RESULTS_RETENTION_DAYS=7

# You shouldn't need to change anything above this line

# Base path to include before generated URLs. If not defined, uses `/`
Expand Down
3 changes: 3 additions & 0 deletions conf/production.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ WWW_SCHEME=http
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
TIME_ZONE=Etc/UTC

## How long to keep test results for
CABOT_RESULTS_RETENTION_DAYS=60

## URL of calendar to synchronise rota with
CALENDAR_ICAL_URL=http://www.google.com/calendar/ical/example.ics

Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
from os import environ as env
import subprocess

from pip.req import parse_requirements
try: # for pip >= 10
from pip._internal.req import parse_requirements
except ImportError: # for pip <= 9.0.3
from pip.req import parse_requirements

requirements = [str(req.req) for req in parse_requirements('requirements.txt', session=False)]
requirements_plugins = [str(req.req) for req in parse_requirements('requirements-plugins.txt', session=False)]
Expand Down