-
Notifications
You must be signed in to change notification settings - Fork 10
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
refactor(obligations): Make separate database tables for classification and type #86
Conversation
3ef7651
to
9af1640
Compare
9af1640
to
7d24fdd
Compare
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.
Changes looks good. Needs test
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.
Few nitpicks, looks good to me.
if licenses[i].Shortname != nil { | ||
erroredLicense = *licenses[i].Shortname | ||
} |
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.
Good one
Classification *ObligationClassification `gorm:"foreignKey:ObligationClassificationId"` | ||
} | ||
|
||
func (o *Obligation) BeforeCreate(tx *gorm.DB) (err error) { |
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 would highly recommend moving all functions out of this file. Probably in the same package but a different file. It somewhat undermines the structure of the project.
Not a blocker.
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.
Yes. What do you think about moving a GORM struct and all it's methods into separate files? Like one for licenses, one for obligations etc.
I'll do it in another PR, this one's already big.
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.
This is a good idea, under models
package, you can separate them into differnt files.
For existing database, these new columns should hold some default values:
|
While trying to pass wrong data, the unmarshling failed which printed some text making the overall response invalid json. can't parse JSON. Raw result:
{"status":500,"message":"Failed to update license","error":"obligation classification must be one of the following values: GREEN WHITE YELLOW RED","path":"/api/v1/obligations/provide license upstream","timestamp":"2024-10-22T10:56:59+05:30"}{"status":200,"data":[{"topic":null,"type":"RISK","text":null,"classification":"WHITTTE","modifications":null,"comment":null,"active":null,"text_updatable":null,"shortnames":[]}],"paginationmeta":{"resource_count":1}} |
7d24fdd
to
a2daf91
Compare
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, working as expected.
Changes
Submitter Checklist
References