Skip to content

Conversation

@ThyMinimalDev
Copy link
Contributor

@ThyMinimalDev ThyMinimalDev commented Jan 15, 2026

What does this PR do?

Adds a new GET /me/event-types endpoint to the API v2 me controller that allows authenticated users to fetch their own event types without needing to specify user identification parameters.

This is a simplified version of the existing GET /event-types endpoint that:

  • Removes query params used to identify which user's event types to fetch (username, eventSlug, usernames, orgSlug, orgId)
  • Uses the authenticated user's ID directly
  • Supports sortCreatedAt query parameter for ordering results by creation date
  • Supports pagination via skip and take query parameters (default: skip=0, take=250)

Link to Devin run: https://app.devin.ai/sessions/9f8ed53fc10c4ab991020371ef976226
Requested by: @ThyMinimalDev

Updates since last revision

  • Added pagination support with skip and take query parameters (extends SkipTakePagination)
  • Updated repository and service methods to pass pagination params through
  • Added e2e tests for pagination scenarios (take only, skip only, skip+take combined)
  • Fixed repository to sort by createdAt instead of id when sortCreatedAt is specified
  • Added secondary sort key (id) for stable pagination when createdAt timestamps tie

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A - API docs are auto-generated from decorators.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Authenticate with a valid API key or access token
  2. Call GET /v2/me/event-types
  3. Verify it returns the authenticated user's event types
  4. Test with ?sortCreatedAt=asc and ?sortCreatedAt=desc to verify sorting works
  5. Test pagination with ?take=2 to limit results
  6. Test pagination with ?skip=1 to skip first result
  7. Test combined pagination with ?skip=1&take=1

Checklist for Human Reviewers

  • Verify e2e tests pass in CI
  • Confirm the transformation using OutputEventTypesService_2024_06_14.getResponseEventType() produces correct output format
  • Verify hidden event types are correctly included for the authenticated owner
  • Verify pagination defaults are appropriate (skip=0, take=250)
  • Verify sorting uses createdAt as primary key and id as secondary key for stable pagination

@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pull-request-size pull-request-size bot added size/L and removed size/M labels Jan 15, 2026
@ThyMinimalDev ThyMinimalDev marked this pull request as ready for review January 15, 2026 16:20
@ThyMinimalDev ThyMinimalDev requested a review from a team as a code owner January 15, 2026 16:20
@graphite-app graphite-app bot added core area: core, team members only foundation labels Jan 15, 2026
Copy link
Contributor

@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 4 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/api/v2/src/ee/me/me.controller.e2e-spec.ts">

<violation number="1" location="apps/api/v2/src/ee/me/me.controller.e2e-spec.ts:371">
P2: The sorting e2e tests compare event type IDs instead of `createdAt`, so they do not actually verify the endpoint’s `sortCreatedAt` behavior.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment on lines +371 to +372
expect(responseBody.data[0].id).toBeLessThan(responseBody.data[1].id);
expect(responseBody.data[1].id).toBeLessThan(responseBody.data[2].id);
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 15, 2026

Choose a reason for hiding this comment

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

P2: The sorting e2e tests compare event type IDs instead of createdAt, so they do not actually verify the endpoint’s sortCreatedAt behavior.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/api/v2/src/ee/me/me.controller.e2e-spec.ts, line 371:

<comment>The sorting e2e tests compare event type IDs instead of `createdAt`, so they do not actually verify the endpoint’s `sortCreatedAt` behavior.</comment>

<file context>
@@ -213,4 +215,184 @@ describe("Me Endpoints", () => {
+      expect(responseBody.data).toBeDefined();
+      expect(responseBody.data?.length).toEqual(3);
+
+      expect(responseBody.data[0].id).toBeLessThan(responseBody.data[1].id);
+      expect(responseBody.data[1].id).toBeLessThan(responseBody.data[2].id);
+    });
</file context>

Fix confidence (alpha): 9/10

Suggested change
expect(responseBody.data[0].id).toBeLessThan(responseBody.data[1].id);
expect(responseBody.data[1].id).toBeLessThan(responseBody.data[2].id);
expect(new Date(responseBody.data[0].createdAt).valueOf()).toBeLessThan(
new Date(responseBody.data[1].createdAt).valueOf()
);
expect(new Date(responseBody.data[1].createdAt).valueOf()).toBeLessThan(
new Date(responseBody.data[2].createdAt).valueOf()
);

✅ Addressed in 3402352

@github-actions
Copy link
Contributor

Devin AI is addressing Cubic AI's review feedback

A Devin session has been created to address the issues identified by Cubic AI.

View Devin Session

devin-ai-integration bot and others added 2 commits January 15, 2026 16:28
The sorting e2e tests were comparing event type IDs instead of createdAt
timestamps, which doesn't actually verify the sortCreatedAt behavior.
Changed assertions to compare createdAt values to properly test the
sorting functionality.

Addresses Cubic AI review feedback (confidence 9/10)

Co-Authored-By: unknown <>
Copy link
Contributor

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

2 issues found across 5 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/api/v2/src/ee/me/me.controller.e2e-spec.ts">

<violation number="1" location="apps/api/v2/src/ee/me/me.controller.e2e-spec.ts:371">
P2: The ascending sort test now asserts the order of `id`s instead of `createdAt`, so it no longer verifies the documented `sortCreatedAt` behavior and could let regressions slip through.</violation>

<violation number="2" location="apps/api/v2/src/ee/me/me.controller.e2e-spec.ts:387">
P2: The descending sort test now compares IDs rather than `createdAt` timestamps, so it cannot detect regressions where `sortCreatedAt=desc` stops sorting by creation time.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

expect(responseBody.data).toBeDefined();
expect(responseBody.data?.length).toEqual(3);

expect(responseBody.data[0].id).toBeGreaterThan(responseBody.data[1].id);
Copy link
Contributor

Choose a reason for hiding this comment

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

P2: The descending sort test now compares IDs rather than createdAt timestamps, so it cannot detect regressions where sortCreatedAt=desc stops sorting by creation time.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/api/v2/src/ee/me/me.controller.e2e-spec.ts, line 387:

<comment>The descending sort test now compares IDs rather than `createdAt` timestamps, so it cannot detect regressions where `sortCreatedAt=desc` stops sorting by creation time.</comment>

<file context>
@@ -388,12 +384,47 @@ describe("Me Endpoints", () => {
-      expect(new Date(responseBody.data[1].createdAt).valueOf()).toBeGreaterThan(
-        new Date(responseBody.data[2].createdAt).valueOf()
-      );
+      expect(responseBody.data[0].id).toBeGreaterThan(responseBody.data[1].id);
+      expect(responseBody.data[1].id).toBeGreaterThan(responseBody.data[2].id);
+    });
</file context>

Fix confidence (alpha): 9/10

Suggested change
expect(responseBody.data[0].id).toBeGreaterThan(responseBody.data[1].id);
expect(new Date(responseBody.data[0].createdAt).valueOf()).toBeGreaterThan(
new Date(responseBody.data[1].createdAt).valueOf()
);

expect(responseBody.data).toBeDefined();
expect(responseBody.data?.length).toEqual(3);

expect(responseBody.data[0].id).toBeLessThan(responseBody.data[1].id);
Copy link
Contributor

Choose a reason for hiding this comment

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

P2: The ascending sort test now asserts the order of ids instead of createdAt, so it no longer verifies the documented sortCreatedAt behavior and could let regressions slip through.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/api/v2/src/ee/me/me.controller.e2e-spec.ts, line 371:

<comment>The ascending sort test now asserts the order of `id`s instead of `createdAt`, so it no longer verifies the documented `sortCreatedAt` behavior and could let regressions slip through.</comment>

<file context>
@@ -368,12 +368,8 @@ describe("Me Endpoints", () => {
-      expect(new Date(responseBody.data[1].createdAt).valueOf()).toBeLessThan(
-        new Date(responseBody.data[2].createdAt).valueOf()
-      );
+      expect(responseBody.data[0].id).toBeLessThan(responseBody.data[1].id);
+      expect(responseBody.data[1].id).toBeLessThan(responseBody.data[2].id);
     });
</file context>

Fix confidence (alpha): 9/10

Suggested change
expect(responseBody.data[0].id).toBeLessThan(responseBody.data[1].id);
expect(new Date(responseBody.data[0].createdAt).valueOf()).toBeLessThan(
new Date(responseBody.data[1].createdAt).valueOf()
);

@github-actions
Copy link
Contributor

github-actions bot commented Jan 15, 2026

Devin AI is addressing Cubic AI's review feedback

New feedback has been sent to the existing Devin session.

View Devin Session


✅ Pushed commit b42f474

The sortCreatedAt parameter was sorting by id instead of createdAt.
This fix ensures the sorting behavior matches the documented parameter name.

Addresses Cubic AI review feedback (confidence 9/10)

Co-Authored-By: [email protected] <[email protected]>
Copy link
Contributor

@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 1 file (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/api/v2/src/ee/event-types/event-types_2024_06_14/event-types.repository.ts">

<violation number="1" location="apps/api/v2/src/ee/event-types/event-types_2024_06_14/event-types.repository.ts:129">
P2: Sorting by `createdAt` alone makes paginated results unstable—add a secondary key (e.g., `id`) so `skip`/`take` do not return duplicates when timestamps tie.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

userId,
},
...(sortCreatedAt && { orderBy: { id: sortCreatedAt } }),
...(sortCreatedAt && { orderBy: { createdAt: sortCreatedAt } }),
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 15, 2026

Choose a reason for hiding this comment

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

P2: Sorting by createdAt alone makes paginated results unstable—add a secondary key (e.g., id) so skip/take do not return duplicates when timestamps tie.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/api/v2/src/ee/event-types/event-types_2024_06_14/event-types.repository.ts, line 129:

<comment>Sorting by `createdAt` alone makes paginated results unstable—add a secondary key (e.g., `id`) so `skip`/`take` do not return duplicates when timestamps tie.</comment>

<file context>
@@ -126,7 +126,7 @@ export class EventTypesRepository_2024_06_14 {
         userId,
       },
-      ...(sortCreatedAt && { orderBy: { id: sortCreatedAt } }),
+      ...(sortCreatedAt && { orderBy: { createdAt: sortCreatedAt } }),
       ...(skip !== undefined && { skip }),
       ...(take !== undefined && { take }),
</file context>

Fix confidence (alpha): 9/10

Suggested change
...(sortCreatedAt && { orderBy: { createdAt: sortCreatedAt } }),
...(sortCreatedAt && { orderBy: [{ createdAt: sortCreatedAt }, { id: sortCreatedAt }] }),

✅ Addressed in fbe2f43

@github-actions
Copy link
Contributor

github-actions bot commented Jan 15, 2026

Devin AI is addressing Cubic AI's review feedback

New feedback has been sent to the existing Devin session.

View Devin Session


✅ Pushed commit fbe2f43

When sorting by createdAt, add id as a secondary sort key to ensure
stable pagination results when timestamps tie. This prevents duplicates
or missing items when using skip/take pagination.

Addresses Cubic AI review feedback (confidence 9/10)

Co-Authored-By: [email protected] <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants