Skip to content

OM-89 - #34

Merged
Andoumeda merged 5 commits into
devfrom
OM-89
Mar 16, 2026
Merged

Andoumeda merged 5 commits into
devfrom
OM-89

Conversation

@leoAchu16

@leoAchu16 leoAchu16 commented Mar 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

Notas de Lanzamiento

  • Nuevas Características
    • Los productos ahora muestran información de la tienda asociada (id y nombre) en listados y detalle.
    • Se agregó calificación promedio, cantidad de reseñas visibles y listado de calificaciones para cada producto.
    • Las reseñas mostradas están filtradas para incluir solo contenido aprobado.

@coderabbitai

coderabbitai Bot commented Mar 16, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Se amplió la respuesta de productos para incluir metadatos de la tienda (store → commerce con id y name), se filtraron reseñas aprobadas (product_reviews con status: true, approved: true) y se añadieron cálculos de calificación (averageRating, reviewCount, ratings).

Changes

Cohort / File(s) Summary
Servicio de Productos
src/modules/commerce/products/product.service.js
Se agregó store a la proyección pública (id_store, name); se añadió filtro product_reviews con selección de rating; se refactorizó mapProductResponse para exponer commerce (id, name), calcular averageRating, reviewCount y generar ratings; cambios menores de formato.

Estimated code review effort

🎯 3 (Moderado) | ⏱️ ~20 minutos

Possibly related PRs

  • OM-77 #19: Modifica la misma área de product.service.js y la proyección de búsqueda de productos (relacionado con inclusión de metadatos de tienda y respuesta de búsqueda).

Suggested reviewers

  • Andoumeda

Poem

🐰
Con tiendas nuevas y estrellas a contar,
mapeo y reseñas comienzan a brillar,
computo promedios, cuento y registro,
salto contento y doy buen visto. 🥕⭐

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive El título consiste solo en un identificador de ticket (OM-89) sin descripción clara de los cambios realizados en el código. Reemplazar el título con una descripción concisa que resuma el cambio principal, como 'Agregar metadatos de comercio y calificaciones promedio a respuestas de productos'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch OM-89
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can use your project's `biome` configuration to improve the quality of JS/TS/CSS/JSON code reviews.

Add a configuration file to your project to customize how CodeRabbit runs biome.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/modules/commerce/products/product.service.js (1)

627-712: Eliminar código comentado.

Este bloque de ~85 líneas contiene una implementación alternativa de getProductByIdService que ya no es necesaria. La implementación activa (líneas 613-624) ya incorpora los cambios requeridos para el ticket OM-89 mediante el uso de PRODUCT_RESPONSE_SELECT y mapProductResponse.

Mantener código comentado genera confusión y dificulta el mantenimiento. Si se necesita referencia histórica, el control de versiones (Git) cumple esa función.

🧹 Eliminar código comentado
-
-
-//---ESTE SERVICE LO HIZO LEO PARA TRAER MAS DETALLES DEL PRODUCTO, BASADO EN LO QUE EXIGE EL TICKET OM-89 DEL SPRINT 2---
-
-/**
- *
-
-export const getProductByIdService = async (id)=>{
-
-  const productId = Number(id);
-
-  if(!Number.isInteger(productId) || productId <= 0){
-
-    throw {
-      status:400,
-      message:"ID de producto inválido"
-    };
-
-  }
-
-  const product = await prisma.products.findFirst({
-
-    where:{
-      id_product:productId,
-      status:true,
-      visible:true
-    },
-
-    select:{
-
-      id_product:true,
-      name:true,
-      description:true,
-      price:true,
-      fk_store:true,
-      visible:true,
-      quantity:true,
-      created_at:true,
-      updated_at:true,
-
-      product_category:{
-        select:{
-          id_product_category:true,
-          name:true,
-          status:true
-        }
-      },
-      
-      store: {
-        select:{
-          id_store:true,
-          name:true
-          //logo:true
-        }
-      },
-
-      product_tag_relations:{
-        where:{status:true},
-
-        select:{
-          product_tag:{
-            select:{
-              id_product_tag:true,
-              name:true
-            }
-          }
-        }
-
-      },
-      product_reviews: {
-        where: { status: true, approved: true },
-        select: { rating: true }
-      }
-
-    }
-
-  });
-
-  if(!product){
-
-    return null;
-
-  }
-  
-  return mapProductResponse(product);
-
-};
- */
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/modules/commerce/products/product.service.js` around lines 627 - 712,
Eliminar el bloque de código comentado que contiene la implementación
alternativa de getProductByIdService (las ~85 líneas dentro del comentario)
porque la versión activa ya usa PRODUCT_RESPONSE_SELECT y mapProductResponse;
simplemente borra todo el comentario multilínea para evitar confusión y dejar
solo la implementación activa de getProductByIdService.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/modules/commerce/products/product.service.js`:
- Around line 627-712: Eliminar el bloque de código comentado que contiene la
implementación alternativa de getProductByIdService (las ~85 líneas dentro del
comentario) porque la versión activa ya usa PRODUCT_RESPONSE_SELECT y
mapProductResponse; simplemente borra todo el comentario multilínea para evitar
confusión y dejar solo la implementación activa de getProductByIdService.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 17a3a28d-4b8a-43b9-9721-1841da6adbcf

📥 Commits

Reviewing files that changed from the base of the PR and between ef0d83b and e7f330a.

📒 Files selected for processing (1)
  • src/modules/commerce/products/product.service.js

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/modules/commerce/products/product.service.js (1)

212-220: Inconsistencia en el nombre del campo entre endpoints.

La respuesta mapeada usa commerce: { id, name }, pero en getProductsSearchService (líneas 592-597) la respuesta retorna store: { id_store, name } directamente del resultado de Prisma. Esto genera inconsistencia en la API:

  • GET /products/:id → commerce.id, commerce.name
  • GET /products?search=... → store.id_store, store.name

Los consumidores de la API tendrán que manejar diferentes nombres de campos para el mismo concepto.

♻️ Sugerencia: aplicar mapProductResponse también en búsqueda o unificar nombres

Opción 1: Usar mapProductResponse también en getProductsSearchService para consistencia total (requiere agregar los campos faltantes al select).

Opción 2: Crear un mapper simplificado para la búsqueda que unifique los nombres:

// En getProductsSearchService, después de obtener products:
const mappedProducts = products.map(p => ({
  id: p.id_product,
  name: p.name,
  description: p.description,
  price: Number(p.price),
  commerce: p.store ? {
    id: p.store.id_store,
    name: p.store.name
  } : null
}));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/modules/commerce/products/product.service.js` around lines 212 - 220, La
respuesta del endpoint de búsqueda es inconsistente con la de detalle:
mapProductResponse usa la propiedad commerce { id, name } mientras
getProductsSearchService devuelve store { id_store, name }, rompiendo el
contrato de API; en getProductsSearchService (o en la función
mapProductResponse) normaliza el mapeo del store a commerce renombrando id_store
a id y envolviendo en commerce: { id, name } para cada producto (p.store →
commerce), o alternativamente aplica mapProductResponse a los resultados de la
búsqueda asegurando que los campos faltantes estén incluidos en el select;
referencia: getProductsSearchService, mapProductResponse, product.store,
commerce, id_store.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/modules/commerce/products/product.service.js`:
- Around line 212-220: La respuesta del endpoint de búsqueda es inconsistente
con la de detalle: mapProductResponse usa la propiedad commerce { id, name }
mientras getProductsSearchService devuelve store { id_store, name }, rompiendo
el contrato de API; en getProductsSearchService (o en la función
mapProductResponse) normaliza el mapeo del store a commerce renombrando id_store
a id y envolviendo en commerce: { id, name } para cada producto (p.store →
commerce), o alternativamente aplica mapProductResponse a los resultados de la
búsqueda asegurando que los campos faltantes estén incluidos en el select;
referencia: getProductsSearchService, mapProductResponse, product.store,
commerce, id_store.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8f3272d3-1927-48ae-896c-d052b5103b5a

📥 Commits

Reviewing files that changed from the base of the PR and between e7f330a and 1527fdd.

📒 Files selected for processing (1)
  • src/modules/commerce/products/product.service.js

@Andoumeda
Andoumeda merged commit ee1c646 into dev Mar 16, 2026
1 check passed
@coderabbitai coderabbitai Bot mentioned this pull request Mar 26, 2026
@Andoumeda
Andoumeda deleted the OM-89 branch March 26, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants