Skip to content

use domain + dto models for events api + cli - #189

Open
TheJolman wants to merge 18 commits into
mainfrom
feat/events-models
Open

use domain + dto models for events api + cli#189
TheJolman wants to merge 18 commits into
mainfrom
feat/events-models

Conversation

@TheJolman

@TheJolman TheJolman commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator

closes #156

@github-actions

github-actions Bot commented Apr 24, 2026

Copy link
Copy Markdown

godoc reference preview ready ✨
Go Documentation

Copilot AI 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.

Pull request overview

This PR refactors the Events API and CLI to use domain.* models for service/business logic and dto.* models for HTTP/CLI payloads, updating API docs and fixtures accordingly.

Changes:

  • Switch Events service and handler layers to operate on domain.Event / domain.UpdateEvent and convert responses to dto.Event.
  • Update CLI event create/update commands (and announcement time parsing) to use dto payloads and shared time parsing helpers.
  • Regenerate Swagger docs and update JSON fixtures for the new DTO shapes.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
utils/time.go Adds shared time layout and parsing helper used by CLI/API flows.
utils/convert.go Removes old byte-slice conversion helpers by commenting them out.
internal/dto/event.go Adds DTO↔domain conversions for events, including update DTO conversion.
internal/domain/event.go Removes UUID field from domain.UpdateEvent.
internal/cli/events/post.go Uses dto.Event and the new time parsing helper when creating events.
internal/cli/events/put.go Uses dto.Event/dto.UpdateEvent and formats/parses timestamps for edits.
internal/cli/announcements/post.go Switches announcement time parsing to the new helper.
internal/cli/announcements/put.go Switches announcement time parsing to the new helper.
internal/api/store/events_mapper.go Updates event update mapping after removing UUID from domain update model.
internal/api/services/event.go Moves service interface to domain models; adds DB↔domain mapping.
internal/api/services/board.go Adds a TODO note about filter types.
internal/api/handlers/event.go Returns DTOs from handlers and updates swagger annotations.
internal/api/docs/swagger.yaml Replaces dbmodels event schemas with DTO event schemas.
internal/api/docs/swagger.json Same as above for JSON swagger.
internal/api/docs/docs.go Same as above for embedded swagger template.
fixtures/event_update_partial.json Updates fixture payload shape to DTO style.
fixtures/event_update_location.json Updates fixture payload shape to DTO style.
fixtures/event_update_full.json Updates fixture payload shape to DTO style.
Comments suppressed due to low confidence (1)

internal/dto/event.go:23

  • ToDomain converts StartAt/EndAt via utils.UnixToTime, which currently interprets the int64 as Unix seconds. In this repo, event timestamps are stored/used as UTC milliseconds (see sql/migrations/000002_create_events.up.sql and fixtures), so this will mis-convert times by ~1000x. Update the conversion (and the reverse DTO mapping) to use milliseconds consistently.
		Uuid:     e.Uuid,
		Location: e.Location,
		StartAt:  utils.UnixToTime(e.StartAt),
		EndAt:    utils.UnixToTime(e.EndAt),
		IsAllDay: e.IsAllDay,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread utils/time.go
Comment thread internal/dto/event.go Outdated
Comment thread utils/time.go
Comment thread internal/api/store/events_mapper.go
Comment thread internal/api/handlers/event.go Outdated
Comment thread utils/convert.go Outdated
@TheJolman
TheJolman marked this pull request as ready for review August 2, 2026 01:57

@GaballaGit GaballaGit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me.

Action item:
Make an issue for the following comment:

// TODO: these filters should probably operate on domain models

@GaballaGit

Copy link
Copy Markdown
Member

wait wrong comment oops, I mean this one:

// TODO: Get event and return it here. Issue is that the generated sqlc func
	// isn't returning the resource, so the service isn't either.

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.

Refactor: decouple sqlc-generated DB models from domain logic

3 participants