-
Notifications
You must be signed in to change notification settings - Fork 26
Store checks metadata in the DB instead of ARA #402
Store checks metadata in the DB instead of ARA #402
Conversation
d75fd86
to
c05cdcf
Compare
c05cdcf
to
d190d7d
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.
Green light from my side 🟢 🚀
return nil, err | ||
func (c *checksService) GetChecksCatalog() (models.ChecksCatalog, error) { | ||
var checksRaw []*models.CheckRaw | ||
result := c.db.Order("payload->>'name'").Find(&checksRaw) |
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.
ahah funny jsonb stuff. At least it works eheh. Will keep this in mind, thanks
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.
lol at that font ligature ->>
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 postgres
specific unfortunately, but it works hehe
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 feel we will need to soon to split entity and models, here it is done already with checkRaw
being the persisted entity and check
being the model
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.
Just to understand better your wording:
entity
DB related structmodel
API related struct
Is this correct?
Do we have some other internal structure to manage data better? I ask this, as we store a lot of data asjsonb
which needs to be unmarshalled at some point.
e6fc429
to
f1fea3e
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.
This looks good, but I see a few problems coming up, which are not specific to this PR, but they are becoming more relevant as we add API endpoints.
The main problem I think is that we need a dedicated package for everything related to the web API, as it has its own data models and potentially will have its own business logic, which should be segregated from the web frontend part. This is not to be done now, of course, but let's keep this in mind.
As I mentioned below, for example, we are mixing models a little bit, and the distinction is not super clear to me.
de2d85c
to
a41ba5d
Compare
Refactor the checks metadata catalog storage, to use the Database instead of ARA.
In order to do so:
checks
, which stores the checks catalog data with the check ID, and the rest of the data as payload. I used this approach, as I expect changes in this structure, so having a json payload makes things easier to avoid migration issues, etc. The changes I expect might be like: add a newpremium
field, split the expected values to other column or table, etc. This is an open discussion: Do you prefer the usage of fixed table structure or json payload modeapi/checks/catalog
, (ApiCreateChecksCatalogtaHandler
) to create the catalog data.PD: Maybe there are some ARA leftovers over there. I will remove everything once we have the checks posting finished too