12345678910111213141516171819202122232425262728293031323334353637 |
- package helper
- import (
- "github.com/gshopify/service-wrapper/model"
- "gshopper.com/gshopify/products/graphql/generated"
- "strconv"
- )
- func ExtractMetaPosition(namespace model.Gid, metas []*generated.Metafield) int64 {
- for _, meta := range metas {
- if meta == nil {
- continue
- }
- if model.Gid(meta.Namespace) != namespace {
- continue
- }
- t := model.MetaFieldType(meta.Type)
- if !t.IsValid() || model.MetaFieldTypeNumberInteger != t {
- continue
- }
- if meta.Key != "position" {
- continue
- }
- i, err := strconv.ParseInt(meta.Value, 10, 64)
- if err != nil {
- i = -1
- }
- return i
- }
- return -1
- }
|