mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 01:15:46 +08:00
remove postgresversion and convert unix timestamp in go
This commit is contained in:
@ -83,15 +83,7 @@ func (m *PostgresMacroEngine) evaluateMacro(name string, args []string) (string,
|
||||
return "", fmt.Errorf("missing time column argument for macro %v", name)
|
||||
}
|
||||
|
||||
pg_version := m.Query.DataSource.JsonData.Get("postgresVersion").MustInt(0)
|
||||
if pg_version >= 80100 {
|
||||
// postgres has to_timestamp(double) starting with 8.1
|
||||
return fmt.Sprintf("%s BETWEEN to_timestamp(%d) AND to_timestamp(%d)", args[0], m.TimeRange.GetFromAsSecondsEpoch(), m.TimeRange.GetToAsSecondsEpoch()), nil
|
||||
}
|
||||
|
||||
// dont use to_timestamp in this macro for redshift compatibility #9566
|
||||
return fmt.Sprintf("%s BETWEEN 'epoch'::timestamptz + %d * '1s'::interval AND 'epoch'::timestamptz + %d * '1s'::interval", args[0], m.TimeRange.GetFromAsSecondsEpoch(), m.TimeRange.GetToAsSecondsEpoch()), nil
|
||||
|
||||
return fmt.Sprintf("%s BETWEEN '%s' AND '%s'", args[0], m.TimeRange.MustGetFrom().UTC().Format(time.RFC3339), m.TimeRange.MustGetTo().UTC().Format(time.RFC3339)), nil
|
||||
case "__timeFrom":
|
||||
return fmt.Sprintf("to_timestamp(%d)", m.TimeRange.GetFromAsSecondsEpoch()), nil
|
||||
case "__timeTo":
|
||||
|
Reference in New Issue
Block a user