<commit_before>package api

import (
	"context"
	"fmt"
	"math"
	"time"

	"github.com/grafana/metrictank/api/models"
	"github.com/grafana/metrictank/consolidation"
	"github.com/grafana/metrictank/mdata"
	"github.com/grafana/metrictank/util"
	"github.com/prometheus/common/model"
	"github.com/prometheus/prometheus/pkg/labels"
	"github.com/prometheus/prometheus/storage"
	"github.com/raintank/worldping-api/pkg/log"
)

// Querier creates a new querier that will operate on the subject server
// it needs the org-id stored in a context value
func (s *Server) Querier(ctx context.Context, min, max int64) (storage.Querier, error) {
	// from what I understand, min/max are nanoseconds. @jlisi can correct this if i'm wrong
	from := uint32(min / 1e9)
	to := uint32(max / 1e9)
	return NewQuerier(ctx, s, from, to, ctx.Value(orgID("org-id")).(int), false), nil
}

// querier implements Prometheus' Querier interface
type querier struct {
	*Server
	from         uint32
	to           uint32
	OrgID        int
	metadataOnly bool
	ctx          context.Context
}

func NewQuerier(ctx context.Context, s *Server, from, to uint32, orgId int, metadataOnly bool) storage.Querier {
	return &querier{
		s,
		from,<commit_msg>milliseconds not nanoseconds for querier function<commit_after>package api

import (
	"context"
	"fmt"
	"math"
	"time"

	"github.com/grafana/metrictank/api/models"
	"github.com/grafana/metrictank/consolidation"
	"github.com/grafana/metrictank/mdata"
	"github.com/grafana/metrictank/util"
	"github.com/prometheus/common/model"
	"github.com/prometheus/prometheus/pkg/labels"
	"github.com/prometheus/prometheus/storage"
	"github.com/raintank/worldping-api/pkg/log"
)

// Querier creates a new querier that will operate on the subject server
// it needs the org-id stored in a context value
func (s *Server) Querier(ctx context.Context, min, max int64) (storage.Querier, error) {
	from := uint32(min / 1000)
	to := uint32(max / 1000)
	return NewQuerier(ctx, s, from, to, ctx.Value(orgID("org-id")).(int), false), nil
}

// querier implements Prometheus' Querier interface
type querier struct {
	*Server
	from         uint32
	to           uint32
	OrgID        int
	metadataOnly bool
	ctx          context.Context
}

func NewQuerier(ctx context.Context, s *Server, from, to uint32, orgId int, metadataOnly bool) storage.Querier {
	return &querier{
		s,
		from,
{'fraction_non_alphanumeric': 0.1173728813559322, 'fraction_numerical': 0.015254237288135594, 'mean_word_length': 3.91875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4005991', 'n_tokens_mistral': 892, 'n_tokens_neox': 843, 'n_words': 210}