Skip to content

Documentar calificacion a deliveries y correcion a la solicitud de pe… - #142

Merged
Benjakr04 merged 2 commits into
devfrom
OM-Orders-Delivery
May 5, 2026
Merged

Benjakr04 merged 2 commits into
devfrom
OM-Orders-Delivery

Conversation

@elianasmz

@elianasmz elianasmz commented May 4, 2026 •

Copy link
Copy Markdown
Collaborator

…dido

Summary by CodeRabbit

Notas de Lanzamiento

  • New Features

    • Se agregó información de entrega a la sesión del usuario.
  • Documentation

    • Se documentaron los endpoints para gestionar reseñas de entrega pendientes.

@coderabbitai

coderabbitai Bot commented May 4, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@elianasmz has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 16 minutes and 6 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c667c5c1-4f13-4687-b20e-a2e03b6d4922

📥 Commits

Reviewing files that changed from the base of the PR and between 475b893 and 55566e7.

📒 Files selected for processing (2)
  • src/config/swagger.config.js
  • src/docs/schemas/index.js
📝 Walkthrough

Walkthrough

Se implementa la funcionalidad de reseñas de entregas mediante la adición de esquemas OpenAPI, la actualización del servicio de entregas para filtrar asignaciones pendientes con datos expandidos, la inclusión de información de entrega en la sesión del usuario, y la documentación Swagger de los endpoints asociados.

Changes

Funcionalidad de Reseñas de Entregas

Layer / File(s) Resumen
Definición de Esquemas
src/docs/schemas/order.schema.js
Se exporta orderSchemas con esquemas OpenAPI para error envelope, ítems/respuestas de reseñas pendientes, y payloads de solicitud/respuesta para crear reseñas (incluyendo validaciones de rating 1–5 y campos requeridos con formato date-time).
Exportación de Esquemas
src/docs/schemas/index.js
Se agrega re-exportación wildcard export * from "./order.schema.js" para exponer los esquemas de orden en el barrel file.
Integración en Swagger
src/config/swagger.config.js
Se importa orderSchemas y se incluye en la agregación components.schemas del spec OpenAPI generado.
Filtrado de Asignaciones Pendientes
src/modules/delivery/delivery/delivery.service.js
getPendingAssignmentsService ahora acepta authUserId, filtra entregas con status: true, selecciona direcciones, detalles de envío, usuario de orden (incluyendo phone y avatar_url), tienda (con store_status), y order_items filtrados con nombres de productos; cambia de findUnique a findFirst.
Paso de Autenticación en Controlador
src/modules/delivery/delivery/delivery.controller.js
getPendingAssignments ahora pasa req.user.id_user junto a deliveryId al servicio.
Inclusión de Información de Entrega en Sesión
src/modules/session/controllers/session.controllers.js
userSession expande la consulta Prisma para incluir delivery (seleccionando id_delivery y status) y retorna id_delivery en la respuesta cuando existe y tiene status: true.
Documentación Swagger de Endpoints
src/modules/users/orders/order.routes.js
Se agregan bloques de documentación OpenAPI para GET /api/orders/pending-delivery-reviews y POST /api/orders/:orderId/delivery-review con descripciones, parámetros, requestBody y esquemas de respuesta/error (200/201, 400/401/403/404/409).

Sequence Diagram

sequenceDiagram
    participant Client
    participant Controller
    participant Session
    participant Service
    participant Database

    Client->>Controller: GET /pending-delivery-reviews
    Controller->>Session: Obtener user.id_user
    Session->>Database: Cargar usuario + delivery + store
    Database-->>Session: Usuario con id_delivery y id_store
    Session-->>Controller: id_user disponible
    Controller->>Service: getPendingAssignmentsService(deliveryId, id_user)
    Service->>Database: Consultar entregas con status=true<br/>filtradas por id_user (opcional)
    Database-->>Service: Entregas + asignaciones pendientes<br/>+ órdenes expandidas<br/>+ detalles tienda/usuario/items
    Service-->>Controller: Asignaciones pendientes enriquecidas
    Controller-->>Client: JSON con reseñas pendientes (200)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • CrisNAC/BackendMarketplace#50: Este PR complementa directamente el PR principal — el PR recuperado introdujo la configuración centralizada de swagger y el índice de esquemas, y el PR principal añade y re-exporta orderSchemas para conectarlo en src/config/swagger.config.js.
  • CrisNAC/BackendMarketplace#53: Los cambios del servicio en el PR principal seleccionan store.store_status y campos expandidos de orden/order_items que fueron agregados por la migración de BD del PR recuperado, relacionándolos a nivel de código/esquema.
  • CrisNAC/BackendMarketplace#115: Ambos PRs modifican el mismo punto de entrada de exportación de esquemas (src/docs/schemas/index.js) y la configuración de Swagger (src/config/swagger.config.js) para agregar nuevos grupos de esquemas (orderSchemas vs reviewReportSchemas).

Suggested reviewers

  • Andoumeda
  • Lianyang1234
  • CrisNAC

Poem

🐰 Con orejas alertas, la reseña llegó,
Esquemas ordenados, el swagger brilló,
Entregas filtradas, usuarios conectados,
Sessions enriquecidas, datos bien guardados,
Del conejito, un salto de alegría si pasó! 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive El título es parcialmente relacionado con los cambios. Se refiere a la documentación de calificaciones de entregas (delivery reviews), que está presente en los cambios; sin embargo, es incompleto y truncado (termina con 'pe…'), lo que reduce su claridad y especificidad. Completar el título de manera clara y específica. Considerar: 'Add Swagger documentation for delivery reviews and fix pending assignments query' o similar, evitando truncamientos.
✅ Passed checks (4 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.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch OM-Orders-Delivery

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/modules/delivery/delivery/delivery.service.js`:
- Around line 84-89: La función getPendingAssignmentsService permite bypass de
autorización porque omite el filtro fk_user cuando authUserId es null/undefined;
cambia la firma para hacer authUserId obligatorio (elimina el comportamiento
nullish), validar al inicio de getPendingAssignmentsService que authUserId está
presente y, si no lo está, lanzar un error (p. ej. throw new Error('authUserId
is required') o un error HTTP adecuado), y ajustar la consulta
prisma.deliveries.findFirst para siempre incluir { fk_user: authUserId } en
where; si necesitas soporte para administradores, añade un parámetro explícito
como bypassOwnership con autorización separada en lugar de permitir
null/undefined.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ac028ebf-f6bb-4890-91fb-3ae5b868da58

📥 Commits

Reviewing files that changed from the base of the PR and between 87938ba and 475b893.

📒 Files selected for processing (7)
  • src/config/swagger.config.js
  • src/docs/schemas/index.js
  • src/docs/schemas/order.schema.js
  • src/modules/delivery/delivery/delivery.controller.js
  • src/modules/delivery/delivery/delivery.service.js
  • src/modules/session/controllers/session.controllers.js
  • src/modules/users/orders/order.routes.js

Comment thread src/modules/delivery/delivery/delivery.service.js
@leoAchu16

Copy link
Copy Markdown
Collaborator

eli tenes conflictos

@sonarqubecloud

sonarqubecloud Bot commented May 5, 2026

Copy link
Copy Markdown

@Benjakr04
Benjakr04 merged commit 0673d83 into dev May 5, 2026
4 checks passed
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.

3 participants