Skip to content

Conversation

@AmarTrebinjac
Copy link
Contributor

No description provided.

@pulumi
Copy link

pulumi bot commented Jan 14, 2026

🍹 The Update (preview) for dailydotdev/api/prod (at 6c12b6a) was successful.

Resource Changes

    Name                                                   Type                                  Operation
~   vpc-native-update-trending-cron                        kubernetes:batch/v1:CronJob           update
~   vpc-native-ws-deployment                               kubernetes:apps/v1:Deployment         update
~   vpc-native-update-tags-str-cron                        kubernetes:batch/v1:CronJob           update
~   vpc-native-validate-active-users-cron                  kubernetes:batch/v1:CronJob           update
+   vpc-native-api-db-migration-16802ef9                   kubernetes:batch/v1:Job               create
~   vpc-native-calculate-top-readers-cron                  kubernetes:batch/v1:CronJob           update
~   vpc-native-post-analytics-clickhouse-cron              kubernetes:batch/v1:CronJob           update
~   vpc-native-update-source-tag-view-cron                 kubernetes:batch/v1:CronJob           update
~   vpc-native-clean-stale-user-transactions-cron          kubernetes:batch/v1:CronJob           update
~   vpc-native-check-analytics-report-cron                 kubernetes:batch/v1:CronJob           update
~   vpc-native-personalized-digest-deployment              kubernetes:apps/v1:Deployment         update
-   vpc-native-api-clickhouse-migration-88d6aeb6           kubernetes:batch/v1:Job               delete
~   vpc-native-clean-zombie-user-companies-cron            kubernetes:batch/v1:CronJob           update
~   vpc-native-update-source-public-threshold-cron         kubernetes:batch/v1:CronJob           update
~   vpc-native-clean-zombie-opportunities-cron             kubernetes:batch/v1:CronJob           update
~   vpc-native-hourly-notification-cron                    kubernetes:batch/v1:CronJob           update
~   vpc-native-post-analytics-history-day-clickhouse-cron  kubernetes:batch/v1:CronJob           update
~   vpc-native-personalized-digest-cron                    kubernetes:batch/v1:CronJob           update
~   vpc-native-private-deployment                          kubernetes:apps/v1:Deployment         update
+   vpc-native-api-clickhouse-migration-16802ef9           kubernetes:batch/v1:Job               create
~   vpc-native-clean-zombie-users-cron                     kubernetes:batch/v1:CronJob           update
~   vpc-native-temporal-deployment                         kubernetes:apps/v1:Deployment         update
~   vpc-native-bg-deployment                               kubernetes:apps/v1:Deployment         update
~   vpc-native-clean-zombie-images-cron                    kubernetes:batch/v1:CronJob           update
~   vpc-native-clean-gifted-plus-cron                      kubernetes:batch/v1:CronJob           update
~   vpc-native-generate-search-invites-cron                kubernetes:batch/v1:CronJob           update
~   vpc-native-deployment                                  kubernetes:apps/v1:Deployment         update
-   vpc-native-api-db-migration-88d6aeb6                   kubernetes:batch/v1:Job               delete
+   api-sub-api.experience-company-enriched-notification   gcp:pubsub/subscription:Subscription  create
~   vpc-native-update-views-cron                           kubernetes:batch/v1:CronJob           update
~   vpc-native-update-current-streak-cron                  kubernetes:batch/v1:CronJob           update
~   vpc-native-update-tag-recommendations-cron             kubernetes:batch/v1:CronJob           update
~   vpc-native-update-highlighted-views-cron               kubernetes:batch/v1:CronJob           update
~   vpc-native-daily-digest-cron                           kubernetes:batch/v1:CronJob           update
~   vpc-native-sync-subscription-with-cio-cron             kubernetes:batch/v1:CronJob           update
~   vpc-native-generic-referral-reminder-cron              kubernetes:batch/v1:CronJob           update
~   vpc-native-user-profile-updated-sync-cron              kubernetes:batch/v1:CronJob           update

@AmarTrebinjac AmarTrebinjac marked this pull request as ready for review January 15, 2026 09:14
@AmarTrebinjac AmarTrebinjac requested review from a team and capJavert as code owners January 15, 2026 09:14
Comment on lines 255 to 260
experienceId: string;
userId: string;
experienceTitle: string;
experienceType: UserExperienceType;
companyId: string;
companyName: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

you maybe want to just do userId, experienceId and companyId and then query the data from DB in worker, easier to maintain then sending the name and actual data that can become stale.

@capJavert
Copy link
Contributor

@claude can you look at the comments and address them

@claude
Copy link

claude bot commented Jan 15, 2026

Claude finished @capJavert's task in 3m 19s —— View job


Addressing Review Comments

I've successfully addressed @capJavert's review feedback by refactoring the PubSub topic to follow the general-purpose pattern outlined in the codebase guidelines.

Tasks:

  • Read review comments and understand the requested changes
  • Examine current PubSub topic implementation
  • Examine worker implementation
  • Refactor PubSub topic to only include identifiers (userId, experienceId, companyId)
  • Update worker to fetch data from database
  • Update tests to work with new structure
  • Commit and push changes

Changes Made

PubSub Topic (src/common/typedPubsub.ts:254)

  • Removed experienceTitle, experienceType, and companyName from the topic payload
  • Now only includes essential identifiers: userId, experienceId, companyId

Worker (src/workers/notifications/experienceCompanyEnrichedNotification.ts)

  • Updated handler to query UserExperience and Company entities from the database
  • Added proper null checks to handle missing data gracefully
  • Worker now fetches its own data instead of relying on the topic payload

CDC Trigger (src/workers/cdc/primary.ts:1627)

  • Updated the event trigger to only send identifiers

Tests (__tests__/workers/notifications/experienceCompanyEnrichedNotification.ts)

  • Updated to save company and experience fixtures before tests
  • Modified test cases to use actual database IDs from fixtures
  • Tests now validate that the worker correctly fetches and uses data from the database

This follows the codebase best practice: "PubSub topics should be general-purpose: Topics should contain only essential identifiers... Subscribers fetch their own data."

--- | Branch

- Updated PubSub schema to only include userId, experienceId, companyId
- Worker now fetches experience and company data from database
- Updated tests to save fixtures and query for actual IDs
- Follows best practice: topics contain only essential identifiers

Co-authored-by: Ante Barić <capJavert@users.noreply.github.com>
@AmarTrebinjac
Copy link
Contributor Author

Claude finished @capJavert's task in 3m 19s —— View job

Addressing Review Comments

I've successfully addressed @capJavert's review feedback by refactoring the PubSub topic to follow the general-purpose pattern outlined in the codebase guidelines.

Tasks:

  • Read review comments and understand the requested changes
  • Examine current PubSub topic implementation
  • Examine worker implementation
  • Refactor PubSub topic to only include identifiers (userId, experienceId, companyId)
  • Update worker to fetch data from database
  • Update tests to work with new structure
  • Commit and push changes

Changes Made

PubSub Topic (src/common/typedPubsub.ts:254)

  • Removed experienceTitle, experienceType, and companyName from the topic payload
  • Now only includes essential identifiers: userId, experienceId, companyId

Worker (src/workers/notifications/experienceCompanyEnrichedNotification.ts)

  • Updated handler to query UserExperience and Company entities from the database
  • Added proper null checks to handle missing data gracefully
  • Worker now fetches its own data instead of relying on the topic payload

CDC Trigger (src/workers/cdc/primary.ts:1627)

  • Updated the event trigger to only send identifiers

Tests (__tests__/workers/notifications/experienceCompanyEnrichedNotification.ts)

  • Updated to save company and experience fixtures before tests
  • Modified test cases to use actual database IDs from fixtures
  • Tests now validate that the worker correctly fetches and uses data from the database

This follows the codebase best practice: "PubSub topics should be general-purpose: Topics should contain only essential identifiers... Subscribers fetch their own data."

--- | Branch

@claude please fix the failing tests.

@claude
Copy link

claude bot commented Jan 15, 2026

Claude finished @AmarTrebinjac's task in 2m 48s —— View job


Fixed Failing Tests

Tasks:

  • Read test file to understand test structure
  • Read worker implementation to verify expected behavior
  • Identify the test failure
  • Fix test failures
  • Commit and push changes

Root Cause

The test was failing due to a non-deterministic database query. The fixture includes two work experiences for userId '1':

  1. "Senior Software Engineer" (current position, endedAt: null)
  2. "Software Engineer" (past position, endedAt: 2021-12-31)

The original query findOneBy({ userId: '1', type: UserExperienceType.Work }) could return either experience, making the test flaky. The test expected "Senior Software Engineer" but sometimes received "Software Engineer" instead.

Fix Applied

Updated the query to be deterministic by adding an additional filter:

const savedExperience = await con
  .getRepository(UserExperience)
  .findOne({
    where: {
      userId: '1',
      type: UserExperienceType.Work,
      endedAt: null, // ← Ensures we get the current position
    },
  });

This ensures the test always retrieves the current work experience ("Senior Software Engineer"), making the test deterministic and preventing future failures.

Changes Committed

  • Fixed work experience query in __tests__/workers/notifications/experienceCompanyEnrichedNotification.ts:40-48
  • Committed as: fix: make work experience query deterministic in test

The tests should now pass consistently in CI.

--- | | Branch

github-actions bot and others added 3 commits January 15, 2026 13:30
The test was failing because there are two work experiences for userId '1',
and findOneBy was non-deterministic. Now we explicitly query for the current
work experience (endedAt: null) to ensure we get the correct fixture.

Co-authored-by: Amar Trebinjac <AmarTrebinjac@users.noreply.github.com>
@AmarTrebinjac AmarTrebinjac enabled auto-merge (squash) January 19, 2026 10:23
@AmarTrebinjac AmarTrebinjac merged commit 35a864b into main Jan 19, 2026
10 checks passed
@AmarTrebinjac AmarTrebinjac deleted the ENG-290 branch January 19, 2026 10:33
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