diff --git a/clevercloud/cron.json b/clevercloud/cron.json index 325a57cb9..f89b7e141 100644 --- a/clevercloud/cron.json +++ b/clevercloud/cron.json @@ -2,6 +2,7 @@ "0 0 * * * $ROOT/clevercloud/siaes_export_all_siae_to_file.sh", "15 0 * * * $ROOT/clevercloud/stats_export_user_download_list_to_file.sh", "30 0 * * * $ROOT/clevercloud/stats_export_user_search_list_to_file.sh", + "0 1 * * * $ROOT/clevercloud/tenders_update_count_fields.sh", "0 7 * * 1 $ROOT/clevercloud/siaes_sync_c1_c4.sh", "10 7 * * 1 $ROOT/clevercloud/siaes_sync_c2_c4.sh", "20 7 * * 1 $ROOT/clevercloud/siaes_update_api_entreprise_fields.sh", diff --git a/clevercloud/siaes_update_count_fields.sh b/clevercloud/siaes_update_count_fields.sh index 3c7711dac..2c559a6bf 100755 --- a/clevercloud/siaes_update_count_fields.sh +++ b/clevercloud/siaes_update_count_fields.sh @@ -1,10 +1,10 @@ #!/bin/bash -l -# Update API ZRR fields for new siaes +# Update siae count fields # Do not run if this env var is not set: -if [[ -z "$CRON_UPDATE_COUNT_FIELDS_ENABLED" ]]; then - echo "CRON_UPDATE_COUNT_FIELDS_ENABLED not set. Exiting..." +if [[ -z "$CRON_UPDATE_SIAE_COUNT_FIELDS_ENABLED" ]]; then + echo "CRON_UPDATE_SIAE_COUNT_FIELDS_ENABLED not set. Exiting..." exit 0 fi @@ -19,5 +19,5 @@ fi # $APP_HOME is set by default by clever cloud. cd $APP_HOME -# django-admin update_count_fields -django-admin update_count_fields --fields etablissement_count +# django-admin update_siae_count_fields +django-admin update_siae_count_fields --fields etablissement_count diff --git a/clevercloud/tenders_update_count_fields.sh b/clevercloud/tenders_update_count_fields.sh new file mode 100755 index 000000000..4e6402739 --- /dev/null +++ b/clevercloud/tenders_update_count_fields.sh @@ -0,0 +1,23 @@ +#!/bin/bash -l + +# Update tender count fields + +# Do not run if this env var is not set: +if [[ -z "$CRON_UPDATE_TENDER_COUNT_FIELDS_ENABLED" ]]; then + echo "CRON_UPDATE_TENDER_COUNT_FIELDS_ENABLED not set. Exiting..." + exit 0 +fi + +# About clever cloud cronjobs: +# https://www.clever-cloud.com/doc/tools/crons/ + +if [[ "$INSTANCE_NUMBER" != "0" ]]; then + echo "Instance number is ${INSTANCE_NUMBER}. Stop here." + exit 0 +fi + +# $APP_HOME is set by default by clever cloud. +cd $APP_HOME + +# django-admin update_tender_count_fields +django-admin update_tender_count_fields diff --git a/lemarche/siaes/management/commands/update_count_fields.py b/lemarche/siaes/management/commands/update_siae_count_fields.py similarity index 91% rename from lemarche/siaes/management/commands/update_count_fields.py rename to lemarche/siaes/management/commands/update_siae_count_fields.py index 5f4280e65..01e6b76b9 100644 --- a/lemarche/siaes/management/commands/update_count_fields.py +++ b/lemarche/siaes/management/commands/update_siae_count_fields.py @@ -24,10 +24,10 @@ class Command(BaseCommand): Note: these fields should be updated automatically on each Siae save() Usage: - python manage.py update_count_fields - python manage.py update_count_fields --id 1 - python manage.py update_count_fields --id 1 --fields user_count - python manage.py update_count_fields --id 1 --fields user_count --fields etablissement_count + python manage.py update_siae_count_fields + python manage.py update_siae_count_fields --id 1 + python manage.py update_siae_count_fields --id 1 --fields user_count + python manage.py update_siae_count_fields --id 1 --fields user_count --fields etablissement_count """ def add_arguments(self, parser): diff --git a/lemarche/tenders/management/commands/update_tender_count_fields.py b/lemarche/tenders/management/commands/update_tender_count_fields.py index 3aab00a83..0d75b17b2 100644 --- a/lemarche/tenders/management/commands/update_tender_count_fields.py +++ b/lemarche/tenders/management/commands/update_tender_count_fields.py @@ -1,4 +1,4 @@ -from lemarche.siaes.models import Tender +from lemarche.tenders.models import Tender from lemarche.utils.commands import BaseCommand