Skip to content

kg: refactor published-concepts-query.js to SELECT.from(PublishedConcepts) #684

Closed

Description

@jung-thomas

Follow-up from PR #679 (Phase 3 Track 3-A, code-review finding).

Context

srv/lib/published-concepts-query.js currently selects from Concepts directly with the publish gate (publishedAt IS NOT NULL AND status='ACTIVE') inlined into the WHERE clause:

const published = await db.run(
  SELECT.from(Concepts)
    .columns('ID', 'slug', 'name', 'description')
    .where({ publishedAt: { '!=': null }, status: 'ACTIVE' })
    .orderBy('slug')
)

The same predicate is declared by the PublishedConcepts CDS view in srv/knowledge-graph-service.cds. This is functionally correct but duplicates the gate predicate in two places. The view exists primarily as an admin-readable surface but the runtime helper duplicates it.

Change

Switch the helper to read from PublishedConcepts:

const { PublishedConcepts } = entities('com.sap.developers.ims')  // adjust namespace if needed
const published = await db.run(
  SELECT.from(PublishedConcepts)
    .columns('ID', 'slug', 'name', 'description')
    .orderBy('slug')
)

Validate that:

  • The existing unit tests in test/unit/srv/published-concepts-query.test.js still pass.
  • The unit-test fixture's in-memory SQLite deploy actually surfaces PublishedConcepts (CDS views may behave differently in SQLite vs HANA — verify the test setup deploys it).

Acceptance

  • Helper selects from PublishedConcepts (no WHERE clause needed).
  • All 7 unit tests in published-concepts-query.test.js still pass.
  • Single source of truth for the publish gate: the CDS view definition.

Refs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions