<commit_before>package datasource

import (
	"encoding/json"
	"fmt"
	"github.com/alexanderzobnin/grafana-zabbix/pkg/timeseries"
	"strconv"
	"time"

	"github.com/bitly/go-simplejson"
	"github.com/grafana/grafana-plugin-sdk-go/backend"
	"github.com/grafana/grafana-plugin-sdk-go/backend/log"
)

const (
	MODE_METRICS   = "0"
	MODE_ITSERVICE = "1"
	MODE_TEXT      = "2"
	MODE_ITEMID    = "3"
	MODE_TRIGGERS  = "4"
	MODE_PROBLEMS  = "5"
)

type DBConnectionPostProcessingRequest struct {
	Query     QueryModel                     `json:"query"`
	TimeRange TimeRangePostProcessingRequest `json:"timeRange"`
	Series    []*timeseries.TimeSeriesData   `json:"series"`
}

type TimeRangePostProcessingRequest struct {
	From int64
	To   int64
}

type ZabbixAPIResourceRequest struct {
	DatasourceId int64                  `json:"datasourceId"`
	Method       string                 `json:"method"`
	Params       map[string]interface{} `json:"params,omitempty"`
}

type ZabbixAPIResourceResponse struct {
	Result interface{} `json:"result,omitempty"`
}

// QueryModel model
type QueryModel struct {
	// Deprecated `mode` field, use QueryType instead
	Mode      int64  `json:"mode"`
	QueryType string `json:"queryType"`

	Group       QueryFilter `json:"group"`
	Host        QueryFilter `json:"host"`
	Application QueryFilter `json:"application"`
	ItemTag     QueryFilter `json:"itemTag"`
	Item        QueryFilter `json:"item"`

	// Item ID mode
	ItemIDs string `json:"itemids,omitempty"`

	Functions []QueryFunction `json:"functions,omitempty"`
	Options   QueryOptions    `json:"options"`

	// Direct from the gRPC interfaces
	RefID         string            `json:"-"`
	TimeRange     backend.TimeRange `json:"-"`
	MaxDataPoints int64             `json:"-"`<commit_msg>Fix alerting query error when query type has numeric type, fixes #1342<commit_after>package datasource

import (
	"encoding/json"
	"fmt"
	"strconv"
	"time"

	"github.com/alexanderzobnin/grafana-zabbix/pkg/timeseries"

	"github.com/bitly/go-simplejson"
	"github.com/grafana/grafana-plugin-sdk-go/backend"
	"github.com/grafana/grafana-plugin-sdk-go/backend/log"
)

const (
	MODE_METRICS   = "0"
	MODE_ITSERVICE = "1"
	MODE_TEXT      = "2"
	MODE_ITEMID    = "3"
	MODE_TRIGGERS  = "4"
	MODE_PROBLEMS  = "5"
)

type DBConnectionPostProcessingRequest struct {
	Query     QueryModel                     `json:"query"`
	TimeRange TimeRangePostProcessingRequest `json:"timeRange"`
	Series    []*timeseries.TimeSeriesData   `json:"series"`
}

type TimeRangePostProcessingRequest struct {
	From int64
	To   int64
}

type ZabbixAPIResourceRequest struct {
	DatasourceId int64                  `json:"datasourceId"`
	Method       string                 `json:"method"`
	Params       map[string]interface{} `json:"params,omitempty"`
}

type ZabbixAPIResourceResponse struct {
	Result interface{} `json:"result,omitempty"`
}

// QueryModel model
type QueryModel struct {
	// Deprecated `mode` field, use QueryType instead
	Mode      int64  `json:"mode"`
	QueryType string `json:"-"`

	Group       QueryFilter `json:"group"`
	Host        QueryFilter `json:"host"`
	Application QueryFilter `json:"application"`
	ItemTag     QueryFilter `json:"itemTag"`
	Item        QueryFilter `json:"item"`

	// Item ID mode
	ItemIDs string `json:"itemids,omitempty"`

	Functions []QueryFunction `json:"functions,omitempty"`
	Options   QueryOptions    `json:"options"`

	// Direct from the gRPC interfaces
	RefID         string            `json:"-"`
	TimeRange     backend.TimeRange `json:"-"`
	MaxDataPoints int64             `json:"-"`
{'fraction_non_alphanumeric': 0.11713483146067416, 'fraction_numerical': 0.010112359550561797, 'mean_word_length': 3.496212121212121, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1969963', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1144, 'n_words': 248}