-
Notifications
You must be signed in to change notification settings - Fork 50
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
Conversation
and level/category to job_errors to support warnings as well as errors
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')), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ( |
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
db/migrations/20250122190038_add_warning_status_and_sub_status_to_work_items.js
Show resolved
Hide resolved
sub_status field to be consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a general question about sub_status and category. I see in work_items we are calling the field sub_status and in job_errors we're calling it category. I believe they are the same thing - would it be better to use the same column name?
CHECK (status IN ('ready', 'queued', 'running', 'successful', 'failed', 'canceled', 'warning')), | ||
ADD COLUMN "sub_status" VARCHAR(255), | ||
ADD CONSTRAINT "work_items_sub_status_check" | ||
CHECK (sub_status IN (null, 'no-data')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should have an enumeration on this field which I think we were calling "category" - we should allow any string and don't need this constraint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
ADD COLUMN "category" VARCHAR(255) DEFAULT 'generic' NOT NULL; | ||
|
||
CREATE INDEX job_errors_level ON job_errors (level); | ||
CREATE INDEX job_errors_category ON job_errors (category) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it matters, but for consistency should we have each statement end in a semi-colon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
DROP INDEX job_errors_category; | ||
DROP_INDEX job_errors_level; | ||
ALTER TABLE "job_errors" | ||
DROP CONSTRAINT "job_errors_category_check", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a job_error_category_check constraint in the up migration - and I don't think we want one so assume this should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -10,7 +10,10 @@ | |||
"allowJs": true, | |||
"noImplicitAny": false, | |||
"sourceMap": true, | |||
"outDir": "built" | |||
"outDir": "built", | |||
"typeRoots": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity what does this fix - anything we should do differently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was having consistent failures from tsc
complaining about not finding types for lots of packages. This tells it where to look. Not sure why no one else has seen these errors.
CHECK (status IN ('ready', 'queued', 'running', 'successful', 'failed', 'canceled', 'warning')), | ||
ADD COLUMN "sub_status" VARCHAR(255); | ||
|
||
CREATE INDEX work_items_sub_status ON work_items (sub_status); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add _index
to index name for consistency. i.e. work_items_sub_status_index
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
CHECK (level IN ('error', 'warning')), | ||
ADD COLUMN "category" VARCHAR(255); | ||
|
||
CREATE INDEX job_errors_level ON job_errors (level); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment with index naming convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
*/ | ||
exports.down = function (knex) { | ||
return knex.schema.raw(` | ||
DROP INDEX job_errors_category; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got - syntax error at or near "DROP_INDEX"
error when running the down migration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ugh - fixed here and in the other migration
ALTER TABLE "job_errors" | ||
DROP COLUMN "category", | ||
DROP CONSTRAINT "job_errors_level_check", | ||
DROP COLUMN "level;" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in level;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to fix the down migration issue.
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully tested the migrations and rollbacks. Verified requests continued to work as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested successfully.
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
PR Acceptance Checklist
Documentation updated (if needed)