Skip to content

chore: added missing endpoint, verifiedby and mv refresh job (CM-1030, CM-1038)#3907

Open
themarolt wants to merge 6 commits intomainfrom
feat/missing-endpoint-and-verifiedby-CM-1030-CM-1038
Open

chore: added missing endpoint, verifiedby and mv refresh job (CM-1030, CM-1038)#3907
themarolt wants to merge 6 commits intomainfrom
feat/missing-endpoint-and-verifiedby-CM-1030-CM-1038

Conversation

@themarolt
Copy link
Contributor

@themarolt themarolt commented Mar 10, 2026

Note

Medium Risk
Touches production DB schema/indexes and adds a new materialized-view refresh job, which could impact query performance/locking and operational load if misconfigured.

Overview
Adds a new public endpoint GET /v1/members/:memberId/project-affiliations that returns per-project contribution counts, maintainer roles (now including maintainerFile/repoFileUrl), and organization affiliations, preferring per-project overrides (memberSegmentAffiliations) with a fallback to work experience affiliations.

Extends API responses and ingestion/enrichment pipelines to persist/return verifiedBy for member identities and work experiences, and adds DB support/perf improvements via new memberSegmentAffiliations.verified/verifiedBy columns plus indexes for project-affiliation lookups.

Introduces a cron job to REFRESH MATERIALIZED VIEW CONCURRENTLY (currently mv_maintainer_roles) every 30 minutes, and sends a Slack alert when any cron job times out.

Written by Cursor Bugbot for commit d60f1b8. This will update automatically on new commits. Configure here.

Signed-off-by: Uroš Marolt <uros@marolt.me>
@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

1 similar comment
@github-actions
Copy link
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@themarolt themarolt changed the title chore: added missing endpoint, verifiedby and mv refresh job chore: added missing endpoint, verifiedby and mv refresh job (CM-1030, CM-1038) Mar 10, 2026
Signed-off-by: Uroš Marolt <uros@marolt.me>
@themarolt themarolt requested a review from joanagmaia March 10, 2026 13:29
organizationLogo: a.organizationLogo ?? null,
verified: a.verified,
verifiedBy: a.verifiedBy ?? null,
source: 'ui',
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason for the source here being hardcoded?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't have a source column in the db for memberSegmentAffiliations table. And since the only time this table is updated is through UI I just set it to ui for now but yea let me know what to set here instead?

Signed-off-by: Uroš Marolt <uros@marolt.me>
Copilot AI review requested due to automatic review settings March 10, 2026 19:36
@CLAassistant
Copy link

CLAassistant commented Mar 10, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for project-affiliation retrieval in the public members API, while standardizing verifiedBy across multiple ingestion/enrichment paths and improving query performance via indexes + a materialized-view refresh job.

Changes:

  • Add public endpoint GET /:memberId/project-affiliations that returns per-project contribution segments with maintainer roles and affiliations (manual overrides with work-experience fallback).
  • Extend integration/enrichment identity payloads and public API outputs to include verifiedBy (normalized to null when absent).
  • Add DB migration for memberSegmentAffiliations.verified/verifiedBy, missing indexes for project-affiliation lookups, and a cron job to refresh mv_maintainer_roles every 30 minutes with Slack timeout alerts.

Reviewed changes

Copilot reviewed 25 out of 27 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
services/libs/integrations/src/integrations/twitter/processData.ts Include verifiedBy on created Twitter identities.
services/libs/integrations/src/integrations/stackoverflow/processData.ts Include verifiedBy on created StackOverflow identities.
services/libs/integrations/src/integrations/slack/processData.ts Include verifiedBy on created Slack identities (username/email).
services/libs/integrations/src/integrations/reddit/processData.ts Include verifiedBy on created Reddit identities.
services/libs/integrations/src/integrations/linkedin/processData.ts Include verifiedBy on created LinkedIn identities.
services/libs/integrations/src/integrations/hackernews/processData.ts Include verifiedBy on created Hacker News identities.
services/libs/integrations/src/integrations/groupsio/processData.ts Include verifiedBy on created Groups.io identities (username/email).
services/libs/integrations/src/integrations/gitlab/processData.ts Include verifiedBy on created GitLab identities (username/email/commit author).
services/libs/integrations/src/integrations/github/processData.ts Include verifiedBy on created GitHub identities (members/orgs/email).
services/libs/integrations/src/integrations/discourse/processData.ts Include verifiedBy on created Discourse identities (username/email).
services/libs/integrations/src/integrations/discord/processData.ts Include verifiedBy on created Discord identities.
services/libs/integrations/src/integrations/devto/processData.ts Include verifiedBy on created Dev.to identities.
services/libs/data-access-layer/src/members/projectAffiliations.ts New DAL queries for project segments, manual segment affiliations, and work-experience affiliations.
services/libs/data-access-layer/src/members/index.ts Export new projectAffiliations DAL module.
services/apps/snowflake_connectors/src/integrations/cvent/event-registrations/transformer.ts Include verifiedBy for Cvent-derived identities.
services/apps/members_enrichment_worker/src/workflows/lf-auth0/enrichMemberWithLFAuth0.ts Include verifiedBy for LF Auth0-enriched identities.
services/apps/cron_service/src/main.ts Add Slack alert on cron job timeout failures.
services/apps/cron_service/src/jobs/refreshMvs.job.ts New cron job to refresh materialized views (currently mv_maintainer_roles).
backend/src/utils/mapper.ts Include verifiedBy in work-experience mapping.
backend/src/database/migrations/V1773139177__add-verified-to-member-segment-affiliations.sql Add verified/verifiedBy columns to memberSegmentAffiliations.
backend/src/database/migrations/V1772799041__add-missing-indexes-for-project-affiliations.sql Add missing indexes for memberId lookups (incl. on mv_maintainer_roles).
backend/src/database/migrations/U1773139177__add-verified-to-member-segment-affiliations.sql Undo migration placeholder.
backend/src/database/migrations/U1772799041__add-missing-indexes-for-project-affiliations.sql Undo migration placeholder.
backend/src/api/public/v1/members/project-affiliations/getProjectAffiliations.ts New public API handler implementing project-affiliation response assembly.
backend/src/api/public/v1/members/index.ts Register new /:memberId/project-affiliations route + scope.
backend/src/api/public/v1/members/identities/verifyMemberIdentity.ts Return verifiedBy in verify-identity response.
backend/src/api/public/v1/members/identities/getMemberIdentities.ts Return verifiedBy in get-identities response.

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

Comment on lines +17 to +29
try {
for (const mv of MATERIALIZED_VIEWS) {
ctx.log.info({ mv }, `Refreshing materialized view: ${mv}`)
const start = performance.now()
await dbConnection.query(`REFRESH MATERIALIZED VIEW CONCURRENTLY "${mv}"`)
const duration = ((performance.now() - start) / 1000.0).toFixed(2)
ctx.log.info({ mv, duration }, `Refreshed materialized view ${mv} in ${duration}s`)
}

ctx.log.info('Materialized view refresh job completed!')
} finally {
await dbConnection.$pool.end()
}
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

getDbConnection caches connections per host+database in-process; calling dbConnection.$pool.end() here will close that cached pool. Since cron jobs run in worker.ts and then immediately process.exit(...), this extra shutdown is redundant and may cause failures if this job later adds more DB queries after the refresh (or if the process stops exiting for any reason). Prefer to omit the explicit $pool.end() (match other cron jobs), or introduce a non-cached/closable connection helper if you need deterministic cleanup.

Suggested change
try {
for (const mv of MATERIALIZED_VIEWS) {
ctx.log.info({ mv }, `Refreshing materialized view: ${mv}`)
const start = performance.now()
await dbConnection.query(`REFRESH MATERIALIZED VIEW CONCURRENTLY "${mv}"`)
const duration = ((performance.now() - start) / 1000.0).toFixed(2)
ctx.log.info({ mv, duration }, `Refreshed materialized view ${mv} in ${duration}s`)
}
ctx.log.info('Materialized view refresh job completed!')
} finally {
await dbConnection.$pool.end()
}
for (const mv of MATERIALIZED_VIEWS) {
ctx.log.info({ mv }, `Refreshing materialized view: ${mv}`)
const start = performance.now()
await dbConnection.query(`REFRESH MATERIALIZED VIEW CONCURRENTLY "${mv}"`)
const duration = ((performance.now() - start) / 1000.0).toFixed(2)
ctx.log.info({ mv, duration }, `Refreshed materialized view ${mv} in ${duration}s`)
}
ctx.log.info('Materialized view refresh job completed!')

Copilot uses AI. Check for mistakes.
Signed-off-by: Uroš Marolt <uros@marolt.me>
Signed-off-by: Uroš Marolt <uros@marolt.me>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

rp."maintainerFile"
FROM mv_maintainer_roles mmr
LEFT JOIN public.repositories r ON r.url = mmr.url
LEFT JOIN git."repositoryProcessing" rp ON rp."repositoryId" = r.id
Copy link

Choose a reason for hiding this comment

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

Join likely references wrong repositories table for maintainerFile

High Severity

The query joins git."repositoryProcessing" rp ON rp."repositoryId" = r.id where r is public.repositories. However, git."repositoryProcessing" was created alongside the git.repositories table (migration V1751459866), so its repositoryId column almost certainly references git.repositories.id, not public.repositories.id. Since these are separate tables with independent UUIDs, the join would never match, causing maintainerFile to always be null.

Fix in Cursor Fix in Web

Signed-off-by: Uroš Marolt <uros@marolt.me>
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.

4 participants