-
Notifications
You must be signed in to change notification settings - Fork 0
fix: Corrección de error al guardar prenda y migración de datos iniciales #49
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
Conversation
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.
Pull request overview
This PR addresses issue #48 by fixing duplicate wardrobe item detection and modernizes the application's data initialization strategy by migrating seed data creation from service constructors to Prisma migrations.
Key Changes
- Fixed duplicate item detection to properly filter by
status: trueanduserId, allowing users to create items with the same name as previously deleted items - Migrated initial data seeding (genders and categories) from service constructors to Prisma migrations, resolving Docker filesystem issues
- Implemented NestJS
OnModuleInitlifecycle hook for admin user creation
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/modules/wardrobe/services/wardrobe.service.ts |
Enhanced verifyItemInCategories to filter by status and userId, added excludeItemId parameter to prevent false positives when updating items, and inlined status verification in update method |
prisma/migrations/20251125024400_v1_7_seed_categories/migration.sql |
Added "Prefiero no decirlo" gender option to migration and fixed SQL formatting |
src/modules/users/services/genders.service.ts |
Removed createDefaultGenders method and unnecessary dependencies (CategoriesService, GenderEnum import) |
src/modules/categories/services/categories.service.ts |
Removed createDefaultCategories method and file system dependencies (fs, path, AdminService) that caused Docker errors |
src/modules/users/users.module.ts |
Removed unnecessary CategoriesModule import |
src/modules/categories/categories.module.ts |
Removed unnecessary AdminModule import |
src/modules/admin/services/admin.service.ts |
Implemented OnModuleInit interface for proper initialization lifecycle and made createAdmin private |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
josueJouvin
left a comment
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.
Segun lo que veo valida por categoria, y si la prenda esta deshabilitada da un mensaje de que la prenda que se quiere agregar esta deshabilitada y el usuario tendria que volver a activarla o funciana normal, osea aunque tenga el mismo nombre y categorias deja que se guarde e internamente solo hace cambio de status?
Se va a trabajar en un próximo PR la reactivación de la prenda, si está desactivada y tiene el mismo nombre, al momento de hacer una petición al endpoint de 'create' |
Resumen de Cambios
Este PR soluciona el issue #48 y migra la creación de datos iniciales (géneros, categorías) a migraciones de Prisma.
1. Fix Issue #48: Error al guardar prenda
Archivo:
src/modules/wardrobe/services/wardrobe.service.tsverifyItemInCategoriesahora filtra porstatus: trueyuserIdexcludeItemIdpara evitar conflictos al editar una prenda2. Migración de géneros a Prisma
Archivo:
prisma/migrations/20251125024400_v1_7_seed_categories/migration.sql3. Limpieza de código - GendersService
Archivo:
src/modules/users/services/genders.service.tscreateDefaultGenders()(ahora se maneja en la migración)AdminServiceyGenderEnum4. Limpieza de código - CategoriesService
Archivo:
src/modules/categories/services/categories.service.tscreateDefaultCategories()(ahora se maneja en la migración)fs,pathyAdminServiceENOENT: no such file or directory, open '/usr/src/app/resources/categories.json'5. AdminService con OnModuleInit
Archivo:
src/modules/admin/services/admin.service.tsOnModuleInitpara crear el admin al iniciar el módulocreateAdmin()ahora es privado6. Limpieza de módulos
UsersModule: Eliminada importación deAdminModuleCategoriesModule: Eliminada importación deAdminModuleFlujo actual de inicialización
Issues relacionados
Closes #48