-
-
Notifications
You must be signed in to change notification settings - Fork 57
Adiciona contador de dias úteis #136
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| import json | ||
| import sys | ||
| from datetime import date | ||
| from workadays.workdays import networkdays | ||
| from rastreio import db | ||
|
|
||
| import aiohttp | ||
|
|
@@ -21,6 +22,20 @@ | |
| finished_code = config['CORREIOS']['FCODE'] | ||
| batch_size = int(config['RASTREIOBOT']['batch_size']) | ||
|
|
||
| def parse_data(delta_dias, delta_dias_uteis): | ||
| if delta_dias == 1: | ||
| data = ' (' + str(delta_dias) + ' dia' | ||
| elif delta_dias > 1: | ||
| data = ' (' + str(delta_dias) + ' dias' | ||
|
|
||
| if delta_dias_uteis == 1: | ||
| data = data + ' – ' + str(delta_dias_uteis) + ' dia útil)' | ||
| elif delta_dias_uteis > 1: | ||
| data = data + ' – ' + str(delta_dias_uteis) + ' dias úteis)' | ||
| elif delta_dias > 0: | ||
| data = data + ')' | ||
|
|
||
| return data | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow! Boa! Só fica melhor se puder adicionar alguns testes pra essa função! 😁
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. estou com um pouco de dificuldade de entender exatamente como fazer, mas vou dar uma olhada
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Esse teste talvez seja um bom exemplo, avisa aqui se não tiver dando certo. |
||
|
|
||
| def parse(code, tabela): | ||
| if len(tabela) < 1: | ||
|
|
@@ -40,15 +55,16 @@ def parse(code, tabela): | |
| ano1 = int(evento['data'].split('/')[2]) | ||
| data1 = date(ano1, mes1, dia1) | ||
| delta = data1 - data0 | ||
| delta_utils = networkdays(data0, data1) | ||
| except Exception: | ||
| delta = 0 | ||
| delta_utils = 0 | ||
| pass | ||
| #print(evento['tipo'], evento['status']) | ||
|
|
||
| data = evento['data'] + ' ' + evento['hora'] | ||
| if delta.days == 1: | ||
| data = data + ' (' + str(delta.days) + ' dia)' | ||
| elif delta.days > 1: | ||
| data = data + ' (' + str(delta.days) + ' dias)' | ||
| data += parse_data(delta.days, delta_utils) | ||
|
|
||
| try: | ||
| local = evento['unidade']['local'] | ||
| except Exception: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Faltou atualizar o
pyproject.tomlcom a nova dependência, né?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Faltou só adicionar o
poetry.lockatualizado. Por isso falhou o teste.