mirror of
https://github.com/ccfos/nightingale.git
synced 2026-03-03 14:38:55 +00:00
Compare commits
8 Commits
change-wor
...
update-wor
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7568119667 | ||
|
|
c93694a2a9 | ||
|
|
cfb8c3b66a | ||
|
|
cb5e62b7bb | ||
|
|
ebfde8d6a0 | ||
|
|
b4dcaebf83 | ||
|
|
fa491e313a | ||
|
|
4fe2b5042f |
@@ -331,30 +331,3 @@ CREATE TABLE `event_pipeline_execution` (
|
||||
ALTER TABLE `builtin_metrics` ADD COLUMN `expression_type` varchar(32) NOT NULL DEFAULT 'promql' COMMENT 'expression type: metric_name or promql';
|
||||
ALTER TABLE `builtin_metrics` ADD COLUMN `metric_type` varchar(191) NOT NULL DEFAULT '' COMMENT 'metric type like counter/gauge';
|
||||
ALTER TABLE `builtin_metrics` ADD COLUMN `extra_fields` text COMMENT 'custom extra fields';
|
||||
|
||||
/* v9 2026-01-16 saved_view */
|
||||
CREATE TABLE `saved_view` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL COMMENT 'view name',
|
||||
`page` varchar(64) NOT NULL COMMENT 'page identifier',
|
||||
`filter` text COMMENT 'filter config (JSON)',
|
||||
`public_cate` int NOT NULL DEFAULT 0 COMMENT 'public category: 0-self, 1-team, 2-all',
|
||||
`gids` text COMMENT 'team group ids (JSON)',
|
||||
`create_at` bigint NOT NULL DEFAULT 0 COMMENT 'create timestamp',
|
||||
`create_by` varchar(64) NOT NULL DEFAULT '' COMMENT 'creator',
|
||||
`update_at` bigint NOT NULL DEFAULT 0 COMMENT 'update timestamp',
|
||||
`update_by` varchar(64) NOT NULL DEFAULT '' COMMENT 'updater',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_page` (`page`),
|
||||
KEY `idx_create_by` (`create_by`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='saved views for pages';
|
||||
|
||||
CREATE TABLE `user_view_favorite` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`view_id` bigint NOT NULL COMMENT 'saved view id',
|
||||
`user_id` bigint NOT NULL COMMENT 'user id',
|
||||
`create_at` bigint NOT NULL DEFAULT 0 COMMENT 'create timestamp',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_view_id` (`view_id`),
|
||||
KEY `idx_user_id` (`user_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='user favorite views';
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ccfos/nightingale/v6/pkg/ctx"
|
||||
"github.com/ccfos/nightingale/v6/pkg/poster"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"github.com/ccfos/nightingale/v6/pkg/poster"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// 执行状态常量
|
||||
|
||||
@@ -531,13 +531,8 @@ func Printf(format string, value interface{}) string {
|
||||
|
||||
switch valType {
|
||||
case reflect.String:
|
||||
strValue := value.(string)
|
||||
// Check if it's a value with unit (contains both digits and non-numeric chars like letters or %)
|
||||
if isValueWithUnit(strValue) {
|
||||
return strValue
|
||||
}
|
||||
// Try converting string to float
|
||||
if floatValue, err := strconv.ParseFloat(strValue, 64); err == nil {
|
||||
if floatValue, err := strconv.ParseFloat(value.(string), 64); err == nil {
|
||||
return fmt.Sprintf(format, floatValue)
|
||||
}
|
||||
return fmt.Sprintf(format, value)
|
||||
@@ -549,32 +544,6 @@ func Printf(format string, value interface{}) string {
|
||||
}
|
||||
}
|
||||
|
||||
// isValueWithUnit checks if a string is a numeric value with unit
|
||||
// e.g., "11.5%", "100MB", "10a" returns true
|
||||
// e.g., "11", "11.11", "-3.14" returns false
|
||||
func isValueWithUnit(s string) bool {
|
||||
if s == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
hasDigit := false
|
||||
hasUnit := false
|
||||
|
||||
for _, r := range s {
|
||||
if r >= '0' && r <= '9' {
|
||||
hasDigit = true
|
||||
} else if r == '.' || r == '-' || r == '+' {
|
||||
// These are valid numeric characters, not units
|
||||
continue
|
||||
} else {
|
||||
// Any other character (letters, %, etc.) is considered a unit
|
||||
hasUnit = true
|
||||
}
|
||||
}
|
||||
|
||||
return hasDigit && hasUnit
|
||||
}
|
||||
|
||||
func floatToTime(v float64) (*time.Time, error) {
|
||||
if math.IsNaN(v) || math.IsInf(v, 0) {
|
||||
return nil, errNaNOrInf
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
templateT "text/template"
|
||||
"encoding/base64"
|
||||
|
||||
"github.com/toolkits/pkg/logger"
|
||||
)
|
||||
|
||||
@@ -64,16 +64,6 @@ var TemplateFuncMap = template.FuncMap{
|
||||
"jsonMarshal": JsonMarshal,
|
||||
"mapDifference": MapDifference,
|
||||
"tagsMapToStr": TagsMapToStr,
|
||||
"b64enc": func(s string) string {
|
||||
return base64.StdEncoding.EncodeToString([]byte(s))
|
||||
},
|
||||
"b64dec": func(s string) string {
|
||||
data, err := base64.StdEncoding.DecodeString(s)
|
||||
if err != nil {
|
||||
return s
|
||||
}
|
||||
return string(data)
|
||||
},
|
||||
}
|
||||
|
||||
// NewTemplateFuncMap copy on write for TemplateFuncMap
|
||||
|
||||
Reference in New Issue
Block a user