code.vegaprotocol.io/vega@v0.79.0/datanode/gateway/graphql/helpers_enum.go (about) 1 // Copyright (C) 2023 Gobalsky Labs Limited 2 // 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU Affero General Public License as 5 // published by the Free Software Foundation, either version 3 of the 6 // License, or (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU Affero General Public License for more details. 12 // 13 // You should have received a copy of the GNU Affero General Public License 14 // along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 package gql 17 18 import ( 19 "fmt" 20 21 types "code.vegaprotocol.io/vega/protos/vega" 22 ) 23 24 func convertDataNodeIntervalToProto(interval string) (types.Interval, error) { 25 switch interval { 26 case "block": 27 return types.Interval_INTERVAL_BLOCK, nil 28 case "1 minute": 29 return types.Interval_INTERVAL_I1M, nil 30 case "5 minutes": 31 return types.Interval_INTERVAL_I5M, nil 32 case "15 minutes": 33 return types.Interval_INTERVAL_I15M, nil 34 case "30 minutes": 35 return types.Interval_INTERVAL_I30M, nil 36 case "1 hour": 37 return types.Interval_INTERVAL_I1H, nil 38 case "4 hours": 39 return types.Interval_INTERVAL_I4H, nil 40 case "6 hours": 41 return types.Interval_INTERVAL_I6H, nil 42 case "8 hours": 43 return types.Interval_INTERVAL_I8H, nil 44 case "12 hours": 45 return types.Interval_INTERVAL_I12H, nil 46 case "1 day": 47 return types.Interval_INTERVAL_I1D, nil 48 case "7 days": 49 return types.Interval_INTERVAL_I7D, nil 50 default: 51 err := fmt.Errorf("failed to convert Interval from GraphQL to Proto: %v", interval) 52 return types.Interval_INTERVAL_UNSPECIFIED, err 53 } 54 }