cantabular

package
v0.0.0-...-86b9d59 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const URL = "https://ftb-api-ext.ons.sensiblecode.io/graphql"

Variables

This section is empty.

Functions

func GeoTypeMap

func GeoTypeMap() map[string]string

func GetDataSet

func GetDataSet(varCode string) string

GetDataSet maps variable code to dataset

func ParseMetric

func ParseMetric(geo, cats Pairs, values IntValues) string

func ParseResp

func ParseResp(query interface{})

ParseResp is used for the command line investigate API commands probably doesn't make sense for REST API

func ShortVarMap

func ShortVarMap() map[string]string

Types

type AuthTripper

type AuthTripper struct {
	User string
	Pass string
}

func (AuthTripper) RoundTrip

func (at AuthTripper) RoundTrip(req *http.Request) (*http.Response, error)

type ClassCodes

type ClassCodes struct {
	Dataset struct {
		Table struct {
			Dimensions []struct {
				Categories Pairs
			}
		} `graphql:"table(variables: [$vars])"`
	} `graphql:"dataset(name: $ds)"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(url, user, pass string) *Client

New returns a reusable Client to be used for Metric and Metadata queries.

func (*Client) Checker

func (cant *Client) Checker(ctx context.Context, state *healthcheck.CheckState) error

func (*Client) QueryMetaData

func (cant *Client) QueryMetaData(ctx context.Context, ds string, nomis bool) (string, error)

func (*Client) QueryMetric

func (cant *Client) QueryMetric(ctx context.Context, ds, geoType, code string) (geoq, catsQL Pairs, values IntValues, err error)
{ dataset(name: "Usual-Residents") {
    table(
      variables: ["LA", "HLQPUK11_T007A"]
    ) {
      dimensions {
        categories {
          label
          code
        }
      }
      values
      error
    }
  }
}

QueryMetric is is a cli query2 could be entrypoint for REST endpoint

func (*Client) QueryMetricFilter

func (cant *Client) QueryMetricFilter(ctx context.Context, ds, geo, geoType, code string) (geoq, catsQL Pairs, values IntValues, err error)
{ dataset(name: "Usual-Residents") {
    table(
      variables: ["COUNTRY", "HLQPUK11_T007A"]
      filters: [{variable: "COUNTRY", codes: ["synE92000001"]}]
    ) {
      dimensions {
        categories {
          label
          code
        }
      }
      values
      error
    }
  }
}

MetricFilter is a cli type query1 could be entrypoint for REST endpoint

func (*Client) SendQueryVars

func (cant *Client) SendQueryVars(ctx context.Context, query interface{}, vars map[string]interface{}) error

type DataSets

type DataSets struct {
	Datasets []struct{ Name graphql.String }
}

list datasets

type IntValues

type IntValues []graphql.Int

type Metadata

type Metadata struct {
	Code       string
	Name       string
	Categories []struct {
		Code string
		Name string
	} `json:"categories"`
}

Metadata is a slow, tactical solution

type Metric

type Metric struct {
	Dataset struct {
		Table struct {
			Dimensions []struct {
				Categories Pairs
			}
			Values IntValues
		} `graphql:"table(variables: [$geotype,$var])"`
	} `graphql:"dataset(name: $ds)"`
}

type MetricFilter

type MetricFilter struct {
	Dataset struct {
		Table struct {
			Dimensions []struct {
				Categories Pairs
			}
			Values IntValues
		} `graphql:"table(variables: [$geotype,$var],filters: [{variable: $geotype, codes: $geos}])"`
	} `graphql:"dataset(name: $ds)"`
}

type Pairs

type Pairs []struct {
	Code  graphql.String
	Label graphql.String
}

type VariableCodes

type VariableCodes struct {
	Dataset struct {
		Variables struct {
			Edges []struct {
				Node struct {
					Name  graphql.String
					Label graphql.String
				}
			}
		}
	} `graphql:"dataset(name: $ds)"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL