aboutsummaryrefslogtreecommitdiffstats
path: root/models/packages/arch/search.go
blob: f35c037b23a5897819ce4001028bc5bf7099323d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package arch

import (
	"context"

	packages_model "code.gitea.io/gitea/models/packages"
	arch_module "code.gitea.io/gitea/modules/packages/arch"
)

// GetRepositories gets all available repositories
func GetRepositories(ctx context.Context, ownerID int64) ([]string, error) {
	return packages_model.GetDistinctPropertyValues(
		ctx,
		packages_model.TypeArch,
		ownerID,
		packages_model.PropertyTypeFile,
		arch_module.PropertyRepository,
		nil,
	)
}

// GetArchitectures gets all available architectures for the given repository
func GetArchitectures(ctx context.Context, ownerID int64, repository string) ([]string, error) {
	return packages_model.GetDistinctPropertyValues(
		ctx,
		packages_model.TypeArch,
		ownerID,
		packages_model.PropertyTypeFile,
		arch_module.PropertyArchitecture,
		&packages_model.DistinctPropertyDependency{
			Name:  arch_module.PropertyRepository,
			Value: repository,
		},
	)
}