<commit_before>package service

import (
	"github.com/go-kit/kit/endpoint"
	"github.com/kolide/kolide-ose/server/kolide"
	"golang.org/x/net/context"
)

type packResponse struct {
	kolide.Pack
	QueryCount      uint   `json:"query_count"`
	TotalHostsCount uint   `json:"total_hosts_count"`
	HostIDs         []uint `json:"host_ids"`
	LabelIDs        []uint `json:"label_ids"`
}

func packResponseForPack(ctx context.Context, svc kolide.Service, pack kolide.Pack) (*packResponse, error) {
	queries, err := svc.GetScheduledQueriesInPack(ctx, pack.ID, kolide.ListOptions{})
	if err != nil {
		return nil, err
	}
	hosts, err := svc.ListHostsInPack(ctx, pack.ID, kolide.ListOptions{})
	if err != nil {
		return nil, err
	}
	hostIDs := make([]uint, len(hosts), len(hosts))
	for _, host := range hosts {
		hostIDs = append(hostIDs, host.ID)
	}
	labels, err := svc.ListLabelsForPack(ctx, pack.ID)
	labelIDs := make([]uint, len(labels), len(labels))
	for _, label := range labels {
		labelIDs = append(labelIDs, label.ID)
	}
	if err != nil {<commit_msg>index into pre-allocated array (#844)<commit_after>package service

import (
	"github.com/go-kit/kit/endpoint"
	"github.com/kolide/kolide-ose/server/kolide"
	"golang.org/x/net/context"
)

type packResponse struct {
	kolide.Pack
	QueryCount      uint   `json:"query_count"`
	TotalHostsCount uint   `json:"total_hosts_count"`
	HostIDs         []uint `json:"host_ids"`
	LabelIDs        []uint `json:"label_ids"`
}

func packResponseForPack(ctx context.Context, svc kolide.Service, pack kolide.Pack) (*packResponse, error) {
	queries, err := svc.GetScheduledQueriesInPack(ctx, pack.ID, kolide.ListOptions{})
	if err != nil {
		return nil, err
	}
	hosts, err := svc.ListHostsInPack(ctx, pack.ID, kolide.ListOptions{})
	if err != nil {
		return nil, err
	}
	hostIDs := make([]uint, len(hosts), len(hosts))
	for i, host := range hosts {
		hostIDs[i] = host.ID
	}
	labels, err := svc.ListLabelsForPack(ctx, pack.ID)
	labelIDs := make([]uint, len(labels), len(labels))
	for i, label := range labels {
		labelIDs[i] = label.ID
	}
	if err != nil {
{'fraction_non_alphanumeric': 0.14925373134328357, 'fraction_numerical': 0.0014443909484833895, 'mean_word_length': 4.274111675126903, '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': '3808819', 'n_tokens_mistral': 775, 'n_tokens_neox': 759, 'n_words': 168}