Updates the property service and store method signatures (#30103)

* Updates the property service and store method signatures

Getters can now receive a `groupID` that narrows down the query if
present, so it's not necessary to check for the group ID on the
returning values from the outside layers.

The Search methods now receive the `groupID` and the `targetID`
explicitly as parameters, incentivizing the use of the indexes that
the underlying tables have on the searches.

* Fix tests

---------

Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Miguel de la Cruz
2025-03-10 15:26:47 +01:00
коммит произвёл GitHub
родитель dd258f5ee5
Коммит c5e6d9f570
13 изменённых файлов: 256 добавлений и 161 удалений

Просмотреть файл

@@ -11,19 +11,24 @@ func (ps *PropertyService) CreatePropertyField(field *model.PropertyField) (*mod
return ps.fieldStore.Create(field)
}
func (ps *PropertyService) GetPropertyField(id string) (*model.PropertyField, error) {
return ps.fieldStore.Get(id)
func (ps *PropertyService) GetPropertyField(groupID, id string) (*model.PropertyField, error) {
return ps.fieldStore.Get(groupID, id)
}
func (ps *PropertyService) GetPropertyFields(ids []string) ([]*model.PropertyField, error) {
return ps.fieldStore.GetMany(ids)
func (ps *PropertyService) GetPropertyFields(groupID string, ids []string) ([]*model.PropertyField, error) {
return ps.fieldStore.GetMany(groupID, ids)
}
func (ps *PropertyService) CountActivePropertyFieldsForGroup(groupID string) (int64, error) {
return ps.fieldStore.CountForGroup(groupID, false)
}
func (ps *PropertyService) SearchPropertyFields(opts model.PropertyFieldSearchOpts) ([]*model.PropertyField, error) {
func (ps *PropertyService) SearchPropertyFields(groupID, targetID string, opts model.PropertyFieldSearchOpts) ([]*model.PropertyField, error) {
// groupID and targetID are part of the search method signature to
// incentivize the use of the database indexes in searches
opts.GroupID = groupID
opts.TargetID = targetID
return ps.fieldStore.SearchPropertyFields(opts)
}

Просмотреть файл

@@ -11,15 +11,19 @@ func (ps *PropertyService) CreatePropertyValue(value *model.PropertyValue) (*mod
return ps.valueStore.Create(value)
}
func (ps *PropertyService) GetPropertyValue(id string) (*model.PropertyValue, error) {
return ps.valueStore.Get(id)
func (ps *PropertyService) GetPropertyValue(groupID, id string) (*model.PropertyValue, error) {
return ps.valueStore.Get(groupID, id)
}
func (ps *PropertyService) GetPropertyValues(ids []string) ([]*model.PropertyValue, error) {
return ps.valueStore.GetMany(ids)
func (ps *PropertyService) GetPropertyValues(groupID string, ids []string) ([]*model.PropertyValue, error) {
return ps.valueStore.GetMany(groupID, ids)
}
func (ps *PropertyService) SearchPropertyValues(opts model.PropertyValueSearchOpts) ([]*model.PropertyValue, error) {
func (ps *PropertyService) SearchPropertyValues(groupID, targetID string, opts model.PropertyValueSearchOpts) ([]*model.PropertyValue, error) {
// groupID and targetID are part of the search method signature to
// incentivize the use of the database indexes in searches
opts.GroupID = groupID
opts.TargetID = targetID
return ps.valueStore.SearchPropertyValues(opts)
}