<commit_before>package visibility

import (
	"github.com/Frostman/aptomi/pkg/slinga"
	"sort"
)

type item struct {
	Name  string `json:"name"`
	Title string `json:"title"`
}

type detail struct {
	UserId       string
	Users        []*item
	Services     []*item
	Dependencies []*item
	Views        []*item
}

func NewDetails(userId string, globalUsers slinga.GlobalUsers, state slinga.ServiceUsageState) detail {
	r := detail{userId, make([]*item, 0), make([]*item, 0), make([]*item, 0), make([]*item, 0)}

	// Users
	userIds := make([]string, 0)
	for userId := range globalUsers.Users {
		userIds = append(userIds, userId)
	}

	sort.Strings(userIds)

	for _, userId := range userIds {
		r.Users = append(r.Users, &item{userId, globalUsers.Users[userId].Name})
	}

	// Dependencies
	depIds := make([]string, 0)
	deps := state.Dependencies.DependenciesByID
	for depId, dep := range deps {
		if dep.UserID != userId {
			continue
		}

		depIds = append(depIds, depId)
	}

	sort.Strings(depIds)

	if len(depIds) > 1 {
		r.Dependencies = append([]*item{{"all", "All"}}, r.Dependencies...)
	}
	for _, depId := range depIds {
		r.Dependencies = append(r.Dependencies, &item{depId, deps[depId].ID})
	}

	// Services
	svcIds := make([]string, 0)
	for svcId, svc := range state.Policy.Services {
		if svc.Owner != userId {<commit_msg>server: add all if users more than 1<commit_after>package visibility

import (
	"github.com/Frostman/aptomi/pkg/slinga"
	"sort"
)

type item struct {
	Name  string `json:"name"`
	Title string `json:"title"`
}

type detail struct {
	UserId       string
	Users        []*item
	Services     []*item
	Dependencies []*item
	Views        []*item
}

func NewDetails(userId string, globalUsers slinga.GlobalUsers, state slinga.ServiceUsageState) detail {
	r := detail{userId, make([]*item, 0), make([]*item, 0), make([]*item, 0), make([]*item, 0)}

	// Users
	userIds := make([]string, 0)
	for userId := range globalUsers.Users {
		userIds = append(userIds, userId)
	}

	sort.Strings(userIds)

	if len(userIds) > 1 {
		r.Users = append([]*item{{"all", "All"}}, r.Users...)
	}
	for _, userId := range userIds {
		r.Users = append(r.Users, &item{userId, globalUsers.Users[userId].Name})
	}

	// Dependencies
	depIds := make([]string, 0)
	deps := state.Dependencies.DependenciesByID
	for depId, dep := range deps {
		if dep.UserID != userId {
			continue
		}

		depIds = append(depIds, depId)
	}

	sort.Strings(depIds)

	if len(depIds) > 1 {
		r.Dependencies = append([]*item{{"all", "All"}}, r.Dependencies...)
	}
	for _, depId := range depIds {
		r.Dependencies = append(r.Dependencies, &item{depId, deps[depId].ID})
	}

	// Services
	svcIds := make([]string, 0)
	for svcId, svc := range state.Policy.Services {
		if svc.Owner != userId {
{'fraction_non_alphanumeric': 0.16382128586996003, 'fraction_numerical': 0.006538321830730113, 'mean_word_length': 3.78125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '2254279', 'n_tokens_mistral': 1040, 'n_tokens_neox': 988, 'n_words': 236}