* MM-43956: Adds post counts by day. * MM-43956: Test data cleanup. Switch from Unix to UnixMilli. * MM-43956: Changes from selecting date data types to strings in SQL. * MM-43956: Fixes date format key. * MM-43956: Adds missing user id scope for 'my' top channels graph. * MM-43956: Adds the ability to group post counts by hour. * MM-43956: Require enterprise or professional license. Reject guests. * MM-43956: Adds license for tests. * MM-43956: Renames function. * MM-43956: Omits future hours from post counts by hour. * MM-43956: Adjust API response grouping to users timezone. * MM-43956: Adds translation. * MM-43956: Adds user's timezone to the data tier for the grouping by day and hour. * MM-43956: Fixes layers. * MM-43956: Lint fix. * MM-43956: Fix store layers. * MM-43956: Switches to default name for time package; changes parameter names to avoid naming conflict. * MM-43956: Updates mocks. Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
80 строки
2.4 KiB
Cheetah
80 строки
2.4 KiB
Cheetah
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
// Code generated by "make store-layers"
|
|
// DO NOT EDIT
|
|
|
|
package timerlayer
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/mattermost/mattermost-server/v6/einterfaces"
|
|
"github.com/mattermost/mattermost-server/v6/model"
|
|
"github.com/mattermost/mattermost-server/v6/store"
|
|
)
|
|
|
|
type {{.Name}} struct {
|
|
store.Store
|
|
Metrics einterfaces.MetricsInterface
|
|
{{range $index, $element := .SubStores}} {{$index}}Store store.{{$index}}Store
|
|
{{end}}
|
|
}
|
|
|
|
{{range $index, $element := .SubStores}}func (s *{{$.Name}}) {{$index}}() store.{{$index}}Store {
|
|
return s.{{$index}}Store
|
|
}
|
|
|
|
{{end}}
|
|
|
|
{{range $index, $element := .SubStores}}type {{$.Name}}{{$index}}Store struct {
|
|
store.{{$index}}Store
|
|
Root *{{$.Name}}
|
|
}
|
|
|
|
{{end}}
|
|
|
|
{{range $substoreName, $substore := .SubStores}}
|
|
{{range $index, $element := $substore.Methods}}
|
|
func (s *{{$.Name}}{{$substoreName}}Store) {{$index}}({{$element.Params | joinParamsWithType}}) {{$element.Results | joinResultsForSignature}} {
|
|
start := time.Now()
|
|
{{if $element.Results | len | eq 0}}
|
|
s.{{$substoreName}}Store.{{$index}}({{$element.Params | joinParams}})
|
|
{{else}}
|
|
{{genResultsVars $element.Results false }} := s.{{$substoreName}}Store.{{$index}}({{$element.Params | joinParams}})
|
|
{{end}}
|
|
elapsed := float64(time.Since(start)) / float64(time.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if {{$element.Results | errorToBoolean}} {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("{{$substoreName}}Store.{{$index}}", success, elapsed)
|
|
{{ with (genResultsVars $element.Results false ) -}}
|
|
}
|
|
return {{ . }}
|
|
{{- else -}}
|
|
}
|
|
{{- end }}
|
|
}
|
|
{{end}}
|
|
{{end}}
|
|
|
|
{{range $index, $element := .Methods}}
|
|
func (s *{{$.Name}}) {{$index}}({{$element.Params | joinParamsWithType}}) {{$element.Results | joinResultsForSignature}} {
|
|
{{if $element.Results | len | eq 0}}s.Store.{{$index}}({{$element.Params | joinParams}})
|
|
{{else}}return s.Store.{{$index}}({{$element.Params | joinParams}})
|
|
{{end}}}
|
|
{{end}}
|
|
|
|
func New(childStore store.Store, metrics einterfaces.MetricsInterface) *{{.Name}} {
|
|
newStore := {{.Name}}{
|
|
Store: childStore,
|
|
Metrics: metrics,
|
|
}
|
|
{{range $substoreName, $substore := .SubStores}}
|
|
newStore.{{$substoreName}}Store = &{{$.Name}}{{$substoreName}}Store{{"{"}}{{$substoreName}}Store: childStore.{{$substoreName}}(), Root: &newStore}{{end}}
|
|
return &newStore
|
|
}
|