Skip to content

Commit

Permalink
chore: add sorting filter for entity type in the list tags api (#1476)
Browse files Browse the repository at this point in the history
Signed-off-by: Alessandro Yuichi Okimoto <[email protected]>
  • Loading branch information
cre8ivejp authored Jan 23, 2025
1 parent 6d4ba10 commit 3a35f75
Show file tree
Hide file tree
Showing 15 changed files with 124 additions and 46 deletions.
13 changes: 11 additions & 2 deletions api-description/web-api.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4715,6 +4715,15 @@ paths:
in: query
required: false
type: string
- name: entityType
in: query
required: false
type: string
enum:
- UNSPECIFIED
- FEATURE_FLAG
- ACCOUNT
default: UNSPECIFIED
tags:
- tag
/webhook/triggers/{token}:
Expand Down Expand Up @@ -4867,10 +4876,10 @@ definitions:
TagEntityType:
type: string
enum:
- UNKNOWN
- UNSPECIFIED
- FEATURE_FLAG
- ACCOUNT
default: UNKNOWN
default: UNSPECIFIED
UpdateAccountV2RequestAccountV2Avatar:
type: object
properties:
Expand Down
4 changes: 2 additions & 2 deletions manifests/bucketeer/charts/web/values.yaml

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion pkg/tag/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (s *TagService) validateCreateTagRquest(req *proto.CreateTagRequest, locali
}
return dt.Err()
}
if req.EntityType == proto.Tag_UNKNOWN {
if req.EntityType == proto.Tag_UNSPECIFIED {
dt, err := statusEntityTypeRequired.WithDetails(&errdetails.LocalizedMessage{
Locale: localizer.GetLocale(),
Message: localizer.MustLocalizeWithTemplate(locale.RequiredFieldTemplate, "entity_type"),
Expand Down Expand Up @@ -212,6 +212,9 @@ func (s *TagService) ListTags(
if req.SearchKeyword != "" {
whereParts = append(whereParts, mysql.NewSearchQuery([]string{"tag.name"}, req.SearchKeyword))
}
if req.EntityType != proto.Tag_UNSPECIFIED {
whereParts = append(whereParts, mysql.NewFilter("tag.entity_type", "=", req.EntityType))
}
orders, err := s.newListTagsOrdersMySQL(req.OrderBy, req.OrderDirection, localizer)
if err != nil {
s.logger.Error(
Expand Down Expand Up @@ -436,6 +439,8 @@ func (s *TagService) newListTagsOrdersMySQL(
column = "tag.created_at"
case proto.ListTagsRequest_UPDATED_AT:
column = "tag.updated_at"
case proto.ListTagsRequest_ENTITY_TYPE:
column = "tag.entity_type"
default:
dt, err := statusInvalidOrderBy.WithDetails(&errdetails.LocalizedMessage{
Locale: localizer.GetLocale(),
Expand Down
Binary file modified proto/auditlog/proto_descriptor.pb
Binary file not shown.
2 changes: 1 addition & 1 deletion proto/event/domain/event.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion proto/proto.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34585,6 +34585,11 @@
"id": 8,
"name": "organization_id",
"type": "string"
},
{
"id": 9,
"name": "entity_type",
"type": "Tag.EntityType"
}
],
"reserved_ids": [
Expand Down Expand Up @@ -35012,6 +35017,9 @@
{
"path": "google/api/field_behavior.proto"
},
{
"path": "google/protobuf/wrappers.proto"
},
{
"path": "protoc-gen-openapiv2/options/annotations.proto"
},
Expand All @@ -35038,7 +35046,7 @@
"name": "Tag.EntityType",
"enum_fields": [
{
"name": "UNKNOWN"
"name": "UNSPECIFIED"
},
{
"name": "FEATURE_FLAG",
Expand Down
Binary file modified proto/tag/proto_descriptor.pb
Binary file not shown.
48 changes: 32 additions & 16 deletions proto/tag/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions proto/tag/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ option go_package = "github.com/bucketeer-io/bucketeer/proto/tag";

import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/wrappers.proto";
import "protoc-gen-openapiv2/options/annotations.proto";

import "proto/tag/tag.proto";
Expand Down Expand Up @@ -61,6 +62,7 @@ message ListTagsRequest {
string search_keyword = 6;
string environment_id = 7;
string organization_id = 8;
Tag.EntityType entity_type = 9;
}

message ListTagsResponse {
Expand Down
38 changes: 19 additions & 19 deletions proto/tag/tag.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion proto/tag/tag.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ option go_package = "github.com/bucketeer-io/bucketeer/proto/tag";

message Tag {
enum EntityType {
UNKNOWN = 0;
UNSPECIFIED = 0;
FEATURE_FLAG = 1;
ACCOUNT = 2;
}
Expand Down
7 changes: 7 additions & 0 deletions ui/web-v2/src/proto/tag/service_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import * as jspb from 'google-protobuf';
import * as google_api_annotations_pb from '../../google/api/annotations_pb';
import * as google_api_field_behavior_pb from '../../google/api/field_behavior_pb';
import * as google_protobuf_wrappers_pb from 'google-protobuf/google/protobuf/wrappers_pb';
import * as protoc_gen_openapiv2_options_annotations_pb from '../../protoc-gen-openapiv2/options/annotations_pb';
import * as proto_tag_tag_pb from '../../proto/tag/tag_pb';

Expand Down Expand Up @@ -168,6 +169,11 @@ export class ListTagsRequest extends jspb.Message {
getOrganizationId(): string;
setOrganizationId(value: string): void;

getEntityType(): proto_tag_tag_pb.Tag.EntityTypeMap[keyof proto_tag_tag_pb.Tag.EntityTypeMap];
setEntityType(
value: proto_tag_tag_pb.Tag.EntityTypeMap[keyof proto_tag_tag_pb.Tag.EntityTypeMap]
): void;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): ListTagsRequest.AsObject;
static toObject(
Expand Down Expand Up @@ -198,6 +204,7 @@ export namespace ListTagsRequest {
searchKeyword: string;
environmentId: string;
organizationId: string;
entityType: proto_tag_tag_pb.Tag.EntityTypeMap[keyof proto_tag_tag_pb.Tag.EntityTypeMap];
};

export interface OrderByMap {
Expand Down
33 changes: 32 additions & 1 deletion ui/web-v2/src/proto/tag/service_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ var google_api_annotations_pb = require('../../google/api/annotations_pb.js');
goog.object.extend(proto, google_api_annotations_pb);
var google_api_field_behavior_pb = require('../../google/api/field_behavior_pb.js');
goog.object.extend(proto, google_api_field_behavior_pb);
var google_protobuf_wrappers_pb = require('google-protobuf/google/protobuf/wrappers_pb.js');
goog.object.extend(proto, google_protobuf_wrappers_pb);
var protoc$gen$openapiv2_options_annotations_pb = require('../../protoc-gen-openapiv2/options/annotations_pb.js');
goog.object.extend(proto, protoc$gen$openapiv2_options_annotations_pb);
var proto_tag_tag_pb = require('../../proto/tag/tag_pb.js');
Expand Down Expand Up @@ -845,7 +847,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) {
orderDirection: jspb.Message.getFieldWithDefault(msg, 5, 0),
searchKeyword: jspb.Message.getFieldWithDefault(msg, 6, ''),
environmentId: jspb.Message.getFieldWithDefault(msg, 7, ''),
organizationId: jspb.Message.getFieldWithDefault(msg, 8, '')
organizationId: jspb.Message.getFieldWithDefault(msg, 8, ''),
entityType: jspb.Message.getFieldWithDefault(msg, 9, 0)
};

if (includeInstance) {
Expand Down Expand Up @@ -920,6 +923,12 @@ proto.bucketeer.tag.ListTagsRequest.deserializeBinaryFromReader = function (
var value = /** @type {string} */ (reader.readString());
msg.setOrganizationId(value);
break;
case 9:
var value = /** @type {!proto.bucketeer.tag.Tag.EntityType} */ (
reader.readEnum()
);
msg.setEntityType(value);
break;
default:
reader.skipField();
break;
Expand Down Expand Up @@ -978,6 +987,10 @@ proto.bucketeer.tag.ListTagsRequest.serializeBinaryToWriter = function (
if (f.length > 0) {
writer.writeString(8, f);
}
f = message.getEntityType();
if (f !== 0.0) {
writer.writeEnum(9, f);
}
};

/**
Expand Down Expand Up @@ -1124,6 +1137,24 @@ proto.bucketeer.tag.ListTagsRequest.prototype.setOrganizationId = function (
return jspb.Message.setProto3StringField(this, 8, value);
};

/**
* optional Tag.EntityType entity_type = 9;
* @return {!proto.bucketeer.tag.Tag.EntityType}
*/
proto.bucketeer.tag.ListTagsRequest.prototype.getEntityType = function () {
return /** @type {!proto.bucketeer.tag.Tag.EntityType} */ (
jspb.Message.getFieldWithDefault(this, 9, 0)
);
};

/**
* @param {!proto.bucketeer.tag.Tag.EntityType} value
* @return {!proto.bucketeer.tag.ListTagsRequest} returns this
*/
proto.bucketeer.tag.ListTagsRequest.prototype.setEntityType = function (value) {
return jspb.Message.setProto3EnumField(this, 9, value);
};

/**
* List of repeated fields within this message type.
* @private {!Array<number>}
Expand Down
Loading

0 comments on commit 3a35f75

Please sign in to comment.