Add status field and data cleaning for location normalization #1251
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
O que esse PR faz?
Implementa base canônica para normalização de dados de localização (Country, State, City) com rastreamento explícito de status de processamento e limpeza de dados brutos.
Status field com 5 valores:
RAW- dado bruto, sem processamento (default)CLEANED- pré-limpoMATCHED- associado a registro canônicoVERIFIED- validado oficialmenteREJECTED- inválido ou irresolvívelData cleaning via
clean_data()methods:strip_tags)API consistente em todos os modelos:
create(),get_or_create(),create_or_update()aceitam parâmetrostatus.Onde a revisão poderia começar?
location/models.py- função utilityclean_text_data()(linhas ~20-38)location/models.py- status field nos modelos City, State, Countrylocation/tests.py- test classesCityStatusTest,StateStatusTest,CountryStatusTestlocation/migrations/0004_add_status_field.py- migraçãoComo este poderia ser testado manualmente?
Algum cenário de contexto que queira dar?
Backward compatible: campo nullable com default "RAW" - registros existentes recebem o default na migração.
Shared utility:
clean_text_data()elimina duplicação de código entre City, State e Country.Migration safety: hardcoded choices na migração previnem quebra se LOCATION_STATUS mudar no futuro.
21 novos testes adicionados. CodeQL scan: 0 alertas.
Quais são tickets relevantes?
Issue sobre normalização de dados de localização (Country, State, City).
Referências
strip_tags: https://docs.djangoproject.com/en/stable/ref/utils/#django.utils.html.strip_tagsOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.