Skip to content

Conversation

@konard
Copy link
Contributor

@konard konard commented Oct 29, 2025

🎯 Исправление нерабочих эндпоинтов shifts

Исправлена работа всех эндпоинтов shifts, добавлены недостающие эндпоинты согласно спецификации API.

📋 Issue Reference

Fixes #22

✨ Что было сделано

Добавлены недостающие эндпоинты:

  1. GET /api/v1/shifts/my

    • Получение списка всех смен текущего аутентифицированного пользователя
    • Поддерживает пагинацию (per_page, page)
    • Фильтры: status (open/closed), date_from, date_to
    • Возвращает данные в формате с пагинацией
  2. GET /api/v1/shifts/my/current

    • Получение текущей активной смены пользователя
    • Возвращает открытую смену (status=open, shift_end=null) или null
    • Формат ответа: {success: true, data: Shift|null, message?: string}

📝 Технические детали

Изменённые файлы:

  • app/Http/Controllers/Api/V1/ShiftController.php - добавлены методы my() и myCurrent()
  • routes/api.php - зарегистрированы новые роуты
  • swagger.yaml - добавлена полная документация для новых эндпоинтов

Особенности реализации:

  • Эндпоинты используют аутентификацию через Sanctum (middleware: auth:sanctum)
  • Поддерживается eager loading связей (user, dealership, replacement)
  • Корректная обработка случая отсутствия активной смены
  • Соответствие формату ответов фронтенда (TaskMateFrontend)

🔗 Связь с другими компонентами

Эти эндпоинты требуются для работы TaskMateFrontend, где они используются в:

  • src/api/shifts.ts - методы getMyShifts() и getMyCurrentShift()
  • Отображение личных смен пользователя
  • Проверка наличия активной смены

✅ Тестирование

  • Код соответствует существующему стилю проекта
  • Использованы те же паттерны, что и в других методах ShiftController
  • CI тесты будут выполнены автоматически при пуше

📊 Swagger документация

Добавлена полная OpenAPI спецификация для обоих эндпоинтов включая:

  • Описание параметров запроса
  • Примеры ответов
  • Коды состояния HTTP
  • Схемы данных

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

konard and others added 2 commits October 29, 2025 16:35
Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: undefined
Added two new endpoints to support user-specific shift operations:

- GET /shifts/my - Returns paginated list of shifts for authenticated user
  with optional filters: status, date_from, date_to
- GET /shifts/my/current - Returns current active shift for authenticated user
  or null if no active shift exists

These endpoints were missing from the API but are expected by TaskMateFrontend
and documented in the frontend's swagger specification.

Changes:
- Added ShiftController::my() method for user's shift history
- Added ShiftController::myCurrent() method for user's current active shift
- Updated routes/api.php to register the new endpoints
- Updated swagger.yaml with complete API documentation for both endpoints

Fixes issue where frontend received 404 error when accessing /shifts/my/current

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard marked this pull request as ready for review October 29, 2025 15:44
@konard
Copy link
Contributor Author

konard commented Oct 29, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

📎 Log file uploaded as GitHub Gist (361KB)
🔗 View complete solution draft log


Now working session is ended, feel free to review and add any feedback on the solution draft.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 3 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="swagger.yaml">

<violation number="1" location="swagger.yaml:2001">
`type: &#39;null&#39;` is not a valid OpenAPI 3.0 schema type, so this schema becomes invalid. Model the nullable Shift by marking the `$ref` as `nullable: true` or using an allowed type.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

data:
oneOf:
- $ref: '#/components/schemas/Shift'
- type: 'null'
Copy link

@cubic-dev-ai cubic-dev-ai bot Oct 29, 2025

Choose a reason for hiding this comment

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

type: 'null' is not a valid OpenAPI 3.0 schema type, so this schema becomes invalid. Model the nullable Shift by marking the $ref as nullable: true or using an allowed type.

Prompt for AI agents
Address the following comment on swagger.yaml at line 2001:

<comment>`type: &#39;null&#39;` is not a valid OpenAPI 3.0 schema type, so this schema becomes invalid. Model the nullable Shift by marking the `$ref` as `nullable: true` or using an allowed type.</comment>

<file context>
@@ -1909,6 +1909,108 @@ paths:
+                  data:
+                    oneOf:
+                      - $ref: &#39;#/components/schemas/Shift&#39;
+                      - type: &#39;null&#39;
+                    nullable: true
+                  message:
</file context>
Fix with Cubic

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