Skip to content

Create batch of adjuncts#1171

Open
donaldgray wants to merge 23 commits intodevelopfrom
feature/create_adjunctbatch
Open

Create batch of adjuncts#1171
donaldgray wants to merge 23 commits intodevelopfrom
feature/create_adjunctbatch

Conversation

@donaldgray
Copy link
Copy Markdown
Member

What does this change?

Adds support for creating batches of adjuncts. The concept of Batch already exists for assets, so this introduces a new AdjunctBatch concept - it is very similar to asset/batches but different enough to warrant new entities etc.

Extend Hydra Model

Resolves #1150

Adjunct HydraModel gains Asset property

API + Engine handle AdjunctBatch

Add new entities:

  • AdjunctBatch - this is the overall record of items/success/failed etc counts for group of adjuncts (equivalent of Batch for assets)
    • Batch and AdjunctBatch are IDeliverableBatch as there is some commonality between them.
    • Rename BatchAssetStatus -> BatchStatus as it's shared between the 2 different batch types.
  • AdjunctBatchAdjunct - collection of all Adjuncts in an AdjunctBatch, maintains a record of processing for adjunct-batches (equivalent of BatchAsset)
    • BatchAsset and AdjunctBatchAdjunct are both IDeliverableBatchItem

Refactored adjunct processing code out of CreateOrUpdateAdjunct and into AdjunctUpsertService. This handles mapping of fields and raising notifications.

As part of extracting to AdjunctUpsertService I updated engine notifications to be sent in batches, which is more efficient. This has resulted in a slight loss of identifying which actual message sending failed as we're no longer sending one at a time but this should be a very rare occurrence so the trade-off seems worthwhile.

New controller for adjunctQueue - currently only supporting POST operations to create a batch.

CreateAdjunctBatch mediatr request, this

  • Validates incoming payload and finds existing adjuncts from DB.
  • Creates a db transaction
  • Iterates through all adjuncts in payload and calls adjunctUpsertService to process
  • Creates batch + assigns batchId to all adjuncts
  • Creates AdjunctBatchAdjunct record with correct status.
  • Commits transaction
  • Send notifications (Engine + Create/Update)

Extend AdjunctConverter to include an overload of ToDlcsModel() - this allows either the short or long-form assetId to be passed.

Use "adjunct" queue name, rather than "default". Saving "default" for assets, introducing a new one will make it clearer the differences. This change won't be immediately obvious but is surface in customer-queue endpoints, it allows customers to see how many items are outstanding in each type of queue.

Refactor IEngineClient to make use of IDeliverable for single async ingest requests. Stick to Asset and Adjunct for batch requests as there are more differences (namely priority or not). Internally refactor EngineClient to share more internally based in IDeliverable type.

Resolves #1149

Other Changes

Add HydraExceptionFilter - this catches any unhandled exceptions. It's essentially replacing HydraController.HandleHydraRequest() so calls to that were removed. The resulting controller code is now clearer to read.

Database Migration

Note

  • Migration name: Add AdjunctBatch
  • What it does: Adds AdjunctBatches table (with sequence adjunct_batch_id_sequence and index on (Customer, Submitted)), AdjunctBatchAdjuncts junction table, and a nullable Batch FK column on Adjuncts.
  • Breaking Change? No — all new tables/columns; existing data unaffected.

@donaldgray donaldgray requested a review from a team as a code owner April 14, 2026 09:19
@donaldgray donaldgray changed the title Feature/create adjunctbatch Create batch of adjuncts Apr 14, 2026
p-kaczynski and others added 23 commits April 14, 2026 13:44
Reuse and rename BatchStatus enum
Rebased work as PR had been merged, some artifacts were left behind.

Also re-added migration as another had been introduced
Not wired up yet but will allow cleaner controller method calls
Removes boilerplate from method calls, single place to deal with
unhandled exceptions. "Friendly" error messages are currently lost with
this change, only those resulting from an unhandled, non-ApiException.

Also allows injection of Logger class for logging exception details
Make more use of IDeliverable interface, add batch operations
Preparation for batch handling
Extracted common code that can be shared by batch logic
Rebase includes exception filter to try..catch and call to
HandleHydraRequest can be removed
This method was added in a parallel change, simplifies the request.
Modified the LinqKit lib to support async requests
Rebased as PR #1170 had been merged
@donaldgray donaldgray force-pushed the feature/create_adjunctbatch branch from 3025bc8 to 439504f Compare April 14, 2026 12:52
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.

Adjunct gains "asset" Adjunct Batch Creation

2 participants