fix: resolve rebase regressions in measurement queries and logging

- restore measurement hierarchy namespace and bay joins
- fix measurement mapping loop variable references
- remove stale grid fuzzy-search filtering
- correct logger caller skip handling
- align parameter field validation tests with supported fields
This commit is contained in:
douxu 2026-07-16 16:59:11 +08:00
parent c6a8ce7991
commit 38f21f3cda
5 changed files with 16 additions and 19 deletions

View File

@ -277,8 +277,8 @@ func GetFullMeasurementSet(ctx context.Context, db *gorm.DB) (*orm.MeasurementSe
measurement.Tag,
)
}
if m.CompNSPath != "" && m.CompNSPath == m.BayTag {
mSet.CompNSPathToMeasTags[m.CompNSPath] = append(mSet.CompNSPathToMeasTags[m.CompNSPath], m.Tag)
if measurement.CompNSPath != "" && measurement.CompNSPath == measurement.BayTag {
mSet.CompNSPathToMeasTags[measurement.CompNSPath] = append(mSet.CompNSPathToMeasTags[measurement.CompNSPath], measurement.Tag)
}
}
return nil

View File

@ -27,8 +27,8 @@ func TestValidateDataObjectField(t *testing.T) {
{name: "bay field is case insensitive", token: "nspath.component.bay.measurement", dataObjectType: constants.DataObjectTypeMeasurement, field: "DATA_SOURCE"},
{name: "bay unsupported", token: "nspath.component.bay.measurement", dataObjectType: constants.DataObjectTypeMeasurement, field: "unknown", wantErr: common.ErrUnsupportedMeasurementField},
{name: "parameter value", token: "nspath.component.rated.attribute", dataObjectType: constants.DataObjectTypeParameter, field: "value"},
{name: "parameter mode", token: "nspath.component.rated.attribute", dataObjectType: constants.DataObjectTypeParameter, field: "mode"},
{name: "parameter rejects name", token: "nspath.component.rated.attribute", dataObjectType: constants.DataObjectTypeParameter, field: "name", wantErr: common.ErrUnsupportedParameterField},
{name: "parameter name", token: "nspath.component.rated.attribute", dataObjectType: constants.DataObjectTypeParameter, field: "name"},
{name: "parameter rejects mode", token: "nspath.component.rated.attribute", dataObjectType: constants.DataObjectTypeParameter, field: "mode", wantErr: common.ErrUnsupportedParameterField},
{name: "component name", token: "nspath.component.component.name", dataObjectType: constants.DataObjectTypeParameter, field: "name"},
{name: "component rejects mode", token: "nspath.component.component.name", dataObjectType: constants.DataObjectTypeParameter, field: "mode", wantErr: common.ErrUnsupportedParameterField},
{name: "parameter rejects size", token: "nspath.component.rated.attribute", dataObjectType: constants.DataObjectTypeParameter, field: "size", wantErr: common.ErrUnsupportedParameterField},

View File

@ -18,8 +18,6 @@ type facade struct {
_logger *zap.Logger
}
const facadeCallerSkip = 2
// Debug define facade func of debug level log
func Debug(ctx context.Context, msg string, kv ...any) {
logFacade().log(ctx, zapcore.DebugLevel, msg, kv...)
@ -41,7 +39,7 @@ func Error(ctx context.Context, msg string, kv ...any) {
}
func (f *facade) log(ctx context.Context, lvl zapcore.Level, msg string, kv ...any) {
f.logSkip(ctx, lvl, 1, msg, kv...)
f.logSkip(ctx, lvl, 0, msg, kv...)
}
func (f *facade) logSkip(ctx context.Context, lvl zapcore.Level, extraSkip int, msg string, kv ...any) {
@ -73,7 +71,7 @@ func InfoSkip(ctx context.Context, extraSkip int, msg string, kv ...any) {
func logFacade() *facade {
fOnce.Do(func() {
f = &facade{
_logger: GetLoggerInstance().WithOptions(zap.AddCallerSkip(facadeCallerSkip)),
_logger: GetLoggerInstance(),
}
})
return f

View File

@ -1264,14 +1264,6 @@ func runFuzzySearch(ctx context.Context, rdb *redis.Client, searchInput string,
termLastPart = term[lastDotIndex+1:]
}
if recommendLenType == constants.FullRecommendLength && hierarchy == constants.GridRecommendHierarchyType {
exists, err := rdb.SIsMember(ctx, constants.RedisAllGridSetKey, termLastPart).Result()
if err != nil || !exists {
logger.Info(ctx, "query key by redis fuzzy search failed or term not in redis all grid set", "query_key", fuzzyInput, "exists", exists, "error", err)
continue
}
}
switch recommendLenType {
case constants.FullRecommendLength:
if result.Term == "" {

View File

@ -76,7 +76,14 @@ const (
// MeasurementTagHierarchy returns measurements together with their owning
// component tags for building the component-to-measurement mapping.
MeasurementTagHierarchy = `SELECT measurement.*, component.tag AS comp_tag
FROM measurement LEFT JOIN component
ON measurement.component_uuid = component.global_uuid`
MeasurementTagHierarchy = `
SELECT measurement.*,
component.tag AS comp_tag,
component.nspath AS comp_nspath,
bay.tag AS bay_tag
FROM measurement
LEFT JOIN component
ON measurement.component_uuid = component.global_uuid
LEFT JOIN bay
ON measurement.bay_uuid = bay.bay_uuid`
)