Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harmony 1996: Add 'empty-result' status to WorkItem class and work-items table #683

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

indiejames
Copy link
Contributor

Jira Issue ID

HARMONY-1996

Description

This PR adds a new status to WorkItem to represent when a service processed the work-item, but produced to data. This is to allow us to provide a better experience for users by not staging empty files.

Local Test Steps

  1. Use dbViz to update a work-item's status to 'empty-result' and verify that this is allowed. (This change will not be visible anywhere until further tickets are worked)
  2. Run a Harmony request and verify that it goes through okay.
  3. Check the status page and workflow UI to make sure the behavior has not changed

PR Acceptance Checklist

  • Acceptance criteria met
  • Tests added/updated (if needed) and passing
  • Documentation updated (if needed)
  • [ x] Harmony in a Box tested? (if changes made to microservices)

db/db.sql Outdated
@@ -80,7 +92,8 @@ CREATE TABLE `work_items` (
`workflowStepIndex` integer not null,
`scrollID` varchar(4096),
`serviceID` varchar(255) not null,
`status` text check (`status` in ('ready', 'queued', 'running', 'successful', 'failed', 'canceled')) not null,
`status` varchar(255) check (`status` in ('ready', 'queued', 'running', 'successful', 'failed', 'canceled', 'warning')) not null,
`subStatus` varchar(255) check (`subStatus` in ('no-data')),
Copy link
Member

Choose a reason for hiding this comment

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

The column name should besub_status to match the Postgres definition.

Copy link
Member

Choose a reason for hiding this comment

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

The value is missing null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

db/db.sql Outdated
CREATE INDEX work_items_jobID_idx ON work_items(jobID);
CREATE INDEX work_items_serviceID_idx ON work_items(serviceID);
CREATE INDEX work_items_status_idx ON work_items(status);
CREATE INDEX work_items_subStatus_idx ON work_items(subStatus);
Copy link
Member

Choose a reason for hiding this comment

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

The column name should besub_status to match the Postgres definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

db/db.sql Outdated
)
) not null default 'error',
`category` varchar(255) check (
`category` in (
Copy link
Collaborator

@vinnyinverso vinnyinverso Jan 24, 2025

Choose a reason for hiding this comment

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

Do we want to have to change this check every time a new category is added in service lib? If we're adding new categories only via pull request in the service lib, it has been validated already by the time it gets to Harmony. This is also missing the existing error categories like "Server", "Forbidden".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point. I'll drop this constraint here as well as in the migration.

@@ -51,6 +51,9 @@ export default class WorkItem extends Record implements WorkItemRecord {
// The status of the operation - see WorkItemStatus
status?: WorkItemStatus;

// The sub-status of the operation - see WorkItemSubStatus
subStatus?: WorkItemSubStatus;
Copy link
Member

Choose a reason for hiding this comment

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

nit: I think we have coding standard to use underscores in new column names. i.e. sub_status.
I commented above that the sub_status name is not consistent in db definition vs migration. If you want to go with subStatus, it is fine with me as long as we make it consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason I thought it could be snake case in the dB, but camel case in the models. I see now that we are not doing that (maybe it doesn't work). I'll make it snake case here.

exports.up = function (knex, Promise) {
return knex.schema.raw(`
ALTER TABLE "work_items"
DROP CONSTRAINT "work_items_status_check",
Copy link
Collaborator

@vinnyinverso vinnyinverso Jan 24, 2025

Choose a reason for hiding this comment

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

Why do you need to drop work_items_status_check before adding it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Same question for the "down" migration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because there is already a constraint with that name. We can't update it, we have to drop it then add it.

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