Skip to content

Commit

Permalink
Adiciona função para limpar strings (#56)
Browse files Browse the repository at this point in the history
* aadiciona função para limpar strings

* altera função clean_string

* Corrige variavel

* Usa parametro default para o banco

* Remove unicode

* Atualiza versão do python

* Corrige problema com isort

---------

Co-authored-by: Ana Paula Gomes <ana.gomes@nubank.com.br>
  • Loading branch information
turquetti and Ana Paula Gomes authored Mar 26, 2023
1 parent adb2f01 commit 2d415ad
Show file tree
Hide file tree
Showing 7 changed files with 345 additions and 340 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
SECRET_KEY=my-secret-key-here
ORGANIZATION_NAME=Dados Abertos de Feira
ORGANIZATION_NAME="Dados Abertos de Feira"
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.8.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
hooks:
- id: flake8
- repo: https://github.com/PyCQA/isort
rev: 5.8.0
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/ambv/black
Expand Down
2 changes: 1 addition & 1 deletion core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

WSGI_APPLICATION = "core.wsgi.application"

default_db = "postgres://postgres:postgres@db:5432/laia"
default_db = config("DATABASE_URL", default="postgres://postgres:postgres@db:5432/laia")
DATABASES = {
"default": dj_database_url.config(
default=default_db, conn_max_age=600, ssl_require=False
Expand Down
9 changes: 8 additions & 1 deletion information_requests/management/commands/import.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import csv
import unicodedata

from dateutil.parser import parse
from django.core.management.base import BaseCommand
Expand All @@ -25,13 +26,19 @@ def handle(self, *args, **options):
parse(row["Data de resposta"]) if row["Data de resposta"] else None
)

def clean_string(string):
new_string = string.lower().replace(" ", "_")
normalized = unicodedata.normalize("NFKD", new_string)
normalized = normalized.encode("ascii", "ignore")
return normalized.decode()

information_request, created = InformationRequest.objects.get_or_create(
sent_at=parse(row["Data de envio"]),
replied_at=replied_at,
public_agency=public_agency,
title=row["Pedido"],
contact=row["Meio de contato"],
status=row["Status"].lower().replace(" ", "_"),
status=clean_string(row["Status"]),
historic=row["Histórico"],
text=row["Texto"],
reply=row["Resposta"],
Expand Down
Loading

0 comments on commit 2d415ad

Please sign in to comment.