From d305332c2320034385ebb39cea898e245edb32ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Tue, 27 Sep 2022 11:34:48 -0300 Subject: [PATCH] =?UTF-8?q?Rotina=20de=20verifica=C3=A7=C3=A3o=20de=20serv?= =?UTF-8?q?i=C3=A7os=20como=20cronjob?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/apps/servicos/jobs/__init__.py | 0 sigi/apps/servicos/jobs/daily/__init__.py | 0 .../jobs/daily/atualiza_uso_servicos.py | 20 +++++++++++++++++++ sigi/apps/servicos/jobs/hourly/__init__.py | 0 sigi/apps/servicos/jobs/monthly/__init__.py | 0 sigi/apps/servicos/jobs/weekly/__init__.py | 0 sigi/apps/servicos/jobs/yearly/__init__.py | 0 7 files changed, 20 insertions(+) create mode 100644 sigi/apps/servicos/jobs/__init__.py create mode 100644 sigi/apps/servicos/jobs/daily/__init__.py create mode 100644 sigi/apps/servicos/jobs/daily/atualiza_uso_servicos.py create mode 100644 sigi/apps/servicos/jobs/hourly/__init__.py create mode 100644 sigi/apps/servicos/jobs/monthly/__init__.py create mode 100644 sigi/apps/servicos/jobs/weekly/__init__.py create mode 100644 sigi/apps/servicos/jobs/yearly/__init__.py diff --git a/sigi/apps/servicos/jobs/__init__.py b/sigi/apps/servicos/jobs/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sigi/apps/servicos/jobs/daily/__init__.py b/sigi/apps/servicos/jobs/daily/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sigi/apps/servicos/jobs/daily/atualiza_uso_servicos.py b/sigi/apps/servicos/jobs/daily/atualiza_uso_servicos.py new file mode 100644 index 0000000..508a489 --- /dev/null +++ b/sigi/apps/servicos/jobs/daily/atualiza_uso_servicos.py @@ -0,0 +1,20 @@ +import datetime +from django_extensions.management.jobs import DailyJob +from sigi.apps.servicos.models import Servico + + +class Job(DailyJob): + help = "Atualiza uso dos serviços" + + def execute(self): + print( + "Atualizando uso dos serviços SEIT." + f" Início: {datetime.datetime.now(): %d/%m/%Y %H:%M:%S}", + end=" ", + ) + queryset = Servico.objects.exclude(url="").exclude( + tipo_servico__string_pesquisa="" + ) + for obj in queryset: + obj.atualiza_data_uso() + print(f"Término: {datetime.datetime.now(): %d/%m/%Y %H:%M:%S}") diff --git a/sigi/apps/servicos/jobs/hourly/__init__.py b/sigi/apps/servicos/jobs/hourly/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sigi/apps/servicos/jobs/monthly/__init__.py b/sigi/apps/servicos/jobs/monthly/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sigi/apps/servicos/jobs/weekly/__init__.py b/sigi/apps/servicos/jobs/weekly/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sigi/apps/servicos/jobs/yearly/__init__.py b/sigi/apps/servicos/jobs/yearly/__init__.py new file mode 100644 index 0000000..e69de29