Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

add function offset() #1621

Merged
merged 1 commit into from
Jan 21, 2020
Merged

add function offset() #1621

merged 1 commit into from
Jan 21, 2020

Conversation

Dieterbe
Copy link
Contributor

@Dieterbe Dieterbe commented Jan 21, 2020

this one was trivial to write.
it's basically exactly the same as scale except we add instead of multiply

diff expr/func_scale.go expr/func_offset.go
10c10
< type FuncScale struct {
---
> type FuncOffset struct {
15,16c15,16
< func NewScale() GraphiteFunc {
< 	return &FuncScale{}
---
> func NewOffset() GraphiteFunc {
> 	return &FuncOffset{}
19c19
< func (s *FuncScale) Signature() ([]Arg, []Arg) {
---
> func (s *FuncOffset) Signature() ([]Arg, []Arg) {
28c28
< func (s *FuncScale) Context(context Context) Context {
---
> func (s *FuncOffset) Context(context Context) Context {
32c32
< func (s *FuncScale) Exec(cache map[Req][]models.Series) ([]models.Series, error) {
---
> func (s *FuncOffset) Exec(cache map[Req][]models.Series) ([]models.Series, error) {
40c40
< 			out = append(out, schema.Point{Val: v.Val * s.factor, Ts: v.Ts})
---
> 			out = append(out, schema.Point{Val: v.Val + s.factor, Ts: v.Ts})
42,43c42,43
< 		series[i].Target = fmt.Sprintf("scale(%s,%f)", serie.Target, s.factor)
< 		series[i].QueryPatt = fmt.Sprintf("scale(%s,%f)", serie.QueryPatt, s.factor)
---
> 		series[i].Target = fmt.Sprintf("offset(%s,%f)", serie.Target, s.factor)
> 		series[i].QueryPatt = fmt.Sprintf("offset(%s,%f)", serie.QueryPatt, s.factor)
                                                                                            

@Dieterbe Dieterbe merged commit b416a08 into master Jan 21, 2020
@Dieterbe Dieterbe deleted the func-offset branch January 21, 2020 10:08
@Dieterbe Dieterbe added this to the sprint-6 milestone Jan 21, 2020
@Dieterbe Dieterbe self-assigned this Jan 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants