From 47f972441107c72f1ffc012746d30a43f8a6507d Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Sat, 15 Oct 2022 13:09:27 -0800 Subject: [PATCH] order labels and locations by name --- backend/internal/repo/repo_labels.go | 1 + backend/internal/repo/repo_locations.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/internal/repo/repo_labels.go b/backend/internal/repo/repo_labels.go index 567b3f8..b899d68 100644 --- a/backend/internal/repo/repo_labels.go +++ b/backend/internal/repo/repo_labels.go @@ -84,6 +84,7 @@ func (r *LabelRepository) GetOneByGroup(ctx context.Context, gid, ld uuid.UUID) func (r *LabelRepository) GetAll(ctx context.Context, groupId uuid.UUID) ([]LabelSummary, error) { return mapLabelsOut(r.db.Label.Query(). Where(label.HasGroupWith(group.ID(groupId))). + Order(ent.Asc(label.FieldName)). WithGroup(). All(ctx), ) diff --git a/backend/internal/repo/repo_locations.go b/backend/internal/repo/repo_locations.go index 7494690..8a60202 100644 --- a/backend/internal/repo/repo_locations.go +++ b/backend/internal/repo/repo_locations.go @@ -94,7 +94,9 @@ func (r *LocationRepository) GetAll(ctx context.Context, groupId uuid.UUID) ([]L locations WHERE locations.group_locations = ? - ` + ORDER BY + locations.name ASC +` rows, err := r.db.Sql().QueryContext(ctx, query, groupId) if err != nil {