Skip to content

Instantly share code, notes, and snippets.

@foxcarlos
Last active June 15, 2021 13:42
Show Gist options
  • Save foxcarlos/184d3332ecd79dbaacc6529af544d868 to your computer and use it in GitHub Desktop.
Save foxcarlos/184d3332ecd79dbaacc6529af544d868 to your computer and use it in GitHub Desktop.
CEG
# Leer sugerencia de Hiaura
https://docs.djangoproject.com/en/3.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_select_related
#Eliminar las migraciones desde Posgresql
# - Entrar a psql
docker exec -it billing-backend_db_1 psql -U billing
# Listar las migraciones
SELECT * FROM django_migration;
# Eliminar o por nombre de la app o directamente por cada ID
delete FROM django_migrations where app='document';
# Primera vez cuando se crea un repo para subirlo al remote branch
git push --set-upstream origin feature/ACC-22-S3
# PASOS PARA RESTAURAR LA BASE RESPALDO USANDO UN TEMPLATE PREVIAMENTE CREADO
# CREAR UN TEMPLATE CON LA ULTIMA INFORMACION DE LA BASE DE DATOS
$ docker exec -it billing-backend_db_1 psql -U billing
ceg=# CREATE DATABASE billing_backup WITH TEMPLATE billing;
ceg=# \c billing_backup;
Luego Salir CRTL+D
# RESTAURAR LA BASE RESPALDO
$ docker exec -it billing-backend_db_1 psql -U billing
ceg_backup=# DROP DATABASE billing;
ceg_backup=# CREATE DATABASE billing WITH TEMPLATE billing_backup;
# FIN
# LLENAR LA BASE DE DATOS TOMANDO UN ARCHIVO DE RESPALDO .TAR
# Borrar la base y crearla de nuevo vacia
docker exec -it billing-backend_db_1 psql -U billing -d postgres -c "DROP DATABASE billing;"
docker exec -it billing-backend_db_1 psql -U billing -d postgres -c "CREATE DATABASE billing;"
# Llenarla con el respaldo DESCARGADO .tar
cat billing-2021-03-23T05-00-02.sql.tar | zcat | sudo docker exec -i billing-backend_db_1 psql -U billing
# FIN
# OPCIONES Y USOS DE DOCKER
# Para Billing Mexico:
# - Si quieres entrar a consola para por ejemplo ejecutar los test o ejecutar un python manage.y shell
docker-compose run api sh
# - Si no corre por algun motivo ipdb entonces correr con los siguientes parametros:
docker-compose run --service-ports api
# Git Flow
https://comprandoengrupo.atlassian.net/wiki/spaces/SIS/pages/1628864773/Git-flow+Adaptaci+n+GEG
# Modelo de RFC
https://comprandoengrupo.atlassian.net/wiki/spaces/DYN/pages/348782731/RFC+-+Alta+de+clientes+en+D365
# VIDEOS QUE SE CONSIDERAN VER
# Famosa Pelicula de Albert que explica com funciona la plataforma (Importante verla para darse una idea)
https://drive.google.com/file/d/1ZVO6_laiURxPODw7GPGuCRkFCzfgT0QC/view
# USUARIO CON PERMISOS PARA HACER PRUEBAS DE COMPRAS EN LA IMPO
Entrar en : http://localhost:8000/django_admin/users/user/
- Buscar armeriaelcabildo@riotel.com.ar
- Cambiarle la contrase;a para que puedas hacer login con ese usuario
- Hacer login http://localhost:4200/#/intranet/impo
# RESOLVER CONFLICTOS DE PULL DESFASADOS
git pull origin el_release
despues fixeas conflictos
git add losarchivosquearreglaste
git commit
git push
# RESOLVER CINFLICTOS DE HEAD DESACOPLADO AL HACER EL COMMIT
fatal: Actualmente no estás en una rama.
Para hacer un push a la historia que lleva al estado actual
(HEAD desacoplado)
Se resuelve apuntandola de nuevo a tu rama
git push origin HEAD:bugfix/CEGI-8647
# CONFIGURAR BILLING MEXICO NUEVA FACTURACION
# Correr Frontend
# Mira los pasos previos aca:
https://bitbucket.org/cegteam/billing-frontend-customer/src/develop/
$ docker-compose up dev
# Correr Backend
# Mira los pasos previos aca:
https://bitbucket.org/cegteam/billing-backend/src/develop/
$ docker-compose up
Luego http://localhost:8000/admin
# Para hacerun migrate detener los contenedores docker que este corriendo y luego
ejecutar:
docker-compose run api ./manage.py migrate
# TEST MEJORES
# Si quieres ver unos tes mejor presentados instalar:
pip install pytest-sugar
# ORGANIZAGRAMA DE SISTEMAS
https://docs.google.com/drawings/d/1Zw0pzK5DV39zceywY9H1bkNCGF-0bE2hYcQ1MZfuvj0/edit
# COMO ES EL FORAMTO DE UNA RAMA
bugfix/CEGI-XXXX DONDE xxxx es el numero que se posee cada issue
# CREAR UNA PULL RQUESTS
- La Pull request debe ir desde tu bugfix a algun release que te hayan indicado
- En Title colocar la siguiente forma: [bugfix/CEGI-8647] Algo descriptivo
- En Descripcion: Un detalle
- Reviewers: indicar 3 personas para que hagan review del codigo
- Close branch: indicar que cierre el branch luego de que sea mergeado
# BUILD EN JENKINS
# Para el Monolito
# Construir el build de una pull requests (Un CI para correr y probar tus cambios)
manual: https://comprandoengrupo.atlassian.net/wiki/spaces/IN/pages/1362755638/Creaci+n+de+ambientes+desde+Jenkins
- Ir a jenkins y buscar tu issue en el campo buscar. Ejemplo: bugfix/cegi-8647
- Luego ir al menu de la izquierda y seleccionar Build Now
# BUILD EN JENKINS
# Para Billing
https://jenkins-dev.cegdev.net
# El Release de billing es algo como (Cambia la version):
https://billing-frontend-customer-release-1-1-0-dev.cegdev.net/
#Entrar al admin de Billing
https://billing-backend-release-1-2-0-dev.cegdev.net/admin
usuario:admin
contrase;a: 5uE4mS71AsfnwSzSWABoaRbO
# ROLLING UPDATE DE AMBIENTES
# Para el Monolito
- Ir al siguiente link:
https://jenkins.comprandoengrupo.com/view/Continuous%20Deployment/job/Perform%20a%20Rolling-Update/build?delay=0sec
O simplemente ir a: https://jenkins.comprandoengrupo.com/
- Luego ir a Continous Deployment / Perform a Rolling-Update / Build with parameters
- Donde dice PARAMETERS sacar donde dice test y colocar el ambiente al cual quieres apuntar, en mi caso tenia un
ambiente diferente al release-4-6-0, yo tenia un ambiente propio llamado recaptcha
# PARA NO TENER QUE INGRESAR UNA CONTRASE;A CUANDO HACES UN PUSH PULL
#Confiogurar las sshkey en bitbucket
https://bitbucket.org/account/settings/ssh-keys/
# TENER LA BASE DE DATOS DE PRIDUCCION EN TU LOCAL
# Descargar base de datos de produccion entrar al link:
https://jenkins.comprandoengrupo.com/job/deploy%20db%20dump/build?delay=0sec
Seleccionar: Si se desea la ultima base de produccion actualizada
CREATE_DB_DUMP_FROM_PROD
UPLOAD_DB_DUMP_TO_S3
DB_DUMP_NAME: None
ENVIRONMENT: test
Nota: Dejas en 'test' porque ese environment no existe, asi no pisa ninguna db y en 'none' porque estas creando una nueva con CREATE DB DUMP, si quisieras pisar con una que ya conoces le pasas ese nombre
# docker-compose exec postgres psql -h postgres -U ceg postgres -c "DROP DATABASE ceg;"
# docker-compose exec postgres psql -h postgres -U ceg postgres -c "CREATE DATABASE ceg;"
# cat ceg-2021-01-20T12-33-17.sql_.tar | zcat | sudo docker exec -i ceg-intranet_postgres_1 psql -U ceg
# PASAR SABER COMO RESTAURAR LA BASE DE DATOS
https://comprandoengrupo.atlassian.net/wiki/spaces/SIS/pages/316735539/Quick+database+restore
# Cargar productos al frontend local luego de levantar tu local
# Ver aqui https://bitbucket.org/cegteam/workspace/snippets/gn5BpR/recreate-published-products-in-mongo
from impo.publication import publish
from impo.models import ImpoPublication
from django.db.models import Q
from impo.models import PublishedProduct
# Delete all published products
PublishedProduct.objects.all().delete()
# Publish the impo publications
for impo in ImpoPublication.objects.filter(Q(status='a') | Q(is_visible_to_staff=True)):
publish(impo)
# CUANDO NO APARECEN CARGADOS LOS PRODUCTOS EN IMPO EN AMBIENTE DE PRUEBA(NOTA: ESTO TIENE QUE VER CON EL AMBIENTE QUE CREA JENKINS PARA HACERLE QA)
1- Entrar a tu django admin: https://backoffice-recaptcha.cegdev.net/django_admin/
2 - Seleccionar leg_container-> luego container en el menu de la izquierda
3 - Seleccionar cualquier contenedor de la lista y luego de la lista de seleccion en la parte inferior seleccionar duplicar contenedores y presionar el boton Ejecutar.
4 - Entrar a la copia creada y tildar la opcion Visible para los clientes y donde dice publicacion impo seleccionar Estado actual: Publicacion activa
5 - Refrescar y debe aparecer
QUERIES DJANGO QUE TE PUEDEN AYUDAR EN CUALQUIERMOMENTO
# Queries para indicadores comerciales
https://comprandoengrupo.atlassian.net/wiki/spaces/SIS/pages/380895233/Queries+-+Indicadores+Comerciales
CONFIGURAR INTRANET
# README para configuracion de Docker
https://comprandoengrupo.atlassian.net/wiki/spaces/SIS/pages/13041764/Docker
# Configurar Angular para el Frontend
# https://comprandoengrupo.atlassian.net/wiki/spaces/SIS/pages/167346183/Intranet+Customers+-+Angular
# correr angular
/home/foxcarlos/desarrollo/angular/ng-ceg/npm run start-ar
# Correr celery
/home/foxcarlos/desarrollo/python/django/ceg-intranet/ceg/celery -A ceg worker -l info -c 4 -B
# Correr Test por primera vez
# pytest --no-cov --create-db
# Correr Test para la app que estas rtabajando
pytest --no-cov -n0 -s aqui_la_folder
# si queres correr con ipdb le agregas un -s -n0
pytest --create-db --no-cov -n0 -s
# CREAR BRANCH DESDE MASTER
git checkout -b bugfix/CEGI-nro de la tarea
# MANUAL DE USO DE COMITIZEN PARA CREAR COMMITS CON UN STANDAR
https://comprandoengrupo.atlassian.net/wiki/spaces/FE/pages/1165590552/Conventional+Commits
# MANUALES DE USOS DE FUNCIONALES USADO POR LOS QA
# https://comprandoengrupo.atlassian.net/wiki/spaces/QUALITY/pages/331218950/Plataforma+asociativa+CEG+Ops
# RELACIONAR COMPA;IAS A USUARIO
from django.contrib.auth.models import User
from authentication.models import Company, Profile
a_company = Company.objects.create(
uid='itdoesnotmatter',
name='DailyPlanet',
rfc='whatever'
)
u = User.objects.get(username__icontains='superman')
u.profile.company = a_company
u.profile.save()
# RELACIONAR PAIS A USUARIO
# If you recently created your user run this first
u = User.objects.last()
comprando = Company.objects.get(id=1)
argentina = Country.objects.get(id=1)
mexico = Country.objects.get(id=6)
agus = User.objects.create(
username='agustin',
password='123123',
email='agustin.enriquez@comprandoengrupo.net',
is_superuser=True,
is_staff=True)
agus.managed_countries.add(argentina)
agus.managed_countries.add(mexico)
agus.company = comprando
agus.save()
# USAR DOCKER SIN SUDO
sudo groupadd docker
sudo usermod -aG docker $USER
# Log out and log back in so that your group membership is re-evaluated.
newgrp docker
docker-compose up --build --no-cache
###############################################################################
CREAR UN TICKET A DEVOPS PARA DAR ACCESO A UN NUEVO INTEGRANTE
ticket a devops
https://comprandoengrupo.atlassian.net/browse/CEGI-14205
En el proyecto ceg desarrollo sistemas
y le pones devops en "components"
issue_type task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment