Skip to content

Commit

Permalink
chore: add sorting filter for entity type in the list tags api
Browse files Browse the repository at this point in the history
Signed-off-by: Alessandro Yuichi Okimoto <[email protected]>
  • Loading branch information
cre8ivejp committed Jan 23, 2025
1 parent 6d4ba10 commit e36a755
Show file tree
Hide file tree
Showing 9 changed files with 218 additions and 115 deletions.
5 changes: 5 additions & 0 deletions api-description/web-api.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4715,6 +4715,11 @@ paths:
in: query
required: false
type: string
- name: entityType
in: query
required: false
type: integer
format: int32
tags:
- tag
/webhook/triggers/{token}:
Expand Down
2 changes: 1 addition & 1 deletion manifests/bucketeer/charts/web/values.yaml

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions pkg/tag/api/api.go
Original file line number Diff line number Diff line change
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 != nil {
whereParts = append(whereParts, mysql.NewFilter("tag.entity_type", "=", req.EntityType.Value))
}
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
8 changes: 8 additions & 0 deletions 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": "google.protobuf.Int32Value"
}
],
"reserved_ids": [
Expand Down Expand Up @@ -35015,6 +35020,9 @@
{
"path": "protoc-gen-openapiv2/options/annotations.proto"
},
{
"path": "google/protobuf/wrappers.proto"
},
{
"path": "proto/tag/tag.proto"
}
Expand Down
Binary file modified proto/tag/proto_descriptor.pb
Binary file not shown.
243 changes: 130 additions & 113 deletions proto/tag/service.pb.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions proto/tag/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ option go_package = "github.com/bucketeer-io/bucketeer/proto/tag";
import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
import "google/protobuf/wrappers.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;
google.protobuf.Int32Value entity_type = 9;
}

message ListTagsResponse {
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 @@ -5,6 +5,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 protoc_gen_openapiv2_options_annotations_pb from '../../protoc-gen-openapiv2/options/annotations_pb';
import * as google_protobuf_wrappers_pb from 'google-protobuf/google/protobuf/wrappers_pb';
import * as proto_tag_tag_pb from '../../proto/tag/tag_pb';

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

hasEntityType(): boolean;
clearEntityType(): void;
getEntityType(): google_protobuf_wrappers_pb.Int32Value | undefined;
setEntityType(value?: google_protobuf_wrappers_pb.Int32Value): 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?: google_protobuf_wrappers_pb.Int32Value.AsObject;
};

export interface OrderByMap {
Expand Down
61 changes: 60 additions & 1 deletion ui/web-v2/src/proto/tag/service_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ var google_api_field_behavior_pb = require('../../google/api/field_behavior_pb.j
goog.object.extend(proto, google_api_field_behavior_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 google_protobuf_wrappers_pb = require('google-protobuf/google/protobuf/wrappers_pb.js');
goog.object.extend(proto, google_protobuf_wrappers_pb);
var proto_tag_tag_pb = require('../../proto/tag/tag_pb.js');
goog.object.extend(proto, proto_tag_tag_pb);
goog.exportSymbol('proto.bucketeer.tag.CreateTagRequest', null, global);
Expand Down Expand Up @@ -845,7 +847,10 @@ 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:
(f = msg.getEntityType()) &&
google_protobuf_wrappers_pb.Int32Value.toObject(includeInstance, f)
};

if (includeInstance) {
Expand Down Expand Up @@ -920,6 +925,14 @@ proto.bucketeer.tag.ListTagsRequest.deserializeBinaryFromReader = function (
var value = /** @type {string} */ (reader.readString());
msg.setOrganizationId(value);
break;
case 9:
var value = new google_protobuf_wrappers_pb.Int32Value();
reader.readMessage(
value,
google_protobuf_wrappers_pb.Int32Value.deserializeBinaryFromReader
);
msg.setEntityType(value);
break;
default:
reader.skipField();
break;
Expand Down Expand Up @@ -978,6 +991,14 @@ proto.bucketeer.tag.ListTagsRequest.serializeBinaryToWriter = function (
if (f.length > 0) {
writer.writeString(8, f);
}
f = message.getEntityType();
if (f != null) {
writer.writeMessage(
9,
f,
google_protobuf_wrappers_pb.Int32Value.serializeBinaryToWriter
);
}
};

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

/**
* optional google.protobuf.Int32Value entity_type = 9;
* @return {?proto.google.protobuf.Int32Value}
*/
proto.bucketeer.tag.ListTagsRequest.prototype.getEntityType = function () {
return /** @type{?proto.google.protobuf.Int32Value} */ (
jspb.Message.getWrapperField(
this,
google_protobuf_wrappers_pb.Int32Value,
9
)
);
};

/**
* @param {?proto.google.protobuf.Int32Value|undefined} value
* @return {!proto.bucketeer.tag.ListTagsRequest} returns this
*/
proto.bucketeer.tag.ListTagsRequest.prototype.setEntityType = function (value) {
return jspb.Message.setWrapperField(this, 9, value);
};

/**
* Clears the message field making it undefined.
* @return {!proto.bucketeer.tag.ListTagsRequest} returns this
*/
proto.bucketeer.tag.ListTagsRequest.prototype.clearEntityType = function () {
return this.setEntityType(undefined);
};

/**
* Returns whether this field is set.
* @return {boolean}
*/
proto.bucketeer.tag.ListTagsRequest.prototype.hasEntityType = function () {
return jspb.Message.getField(this, 9) != null;
};

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

0 comments on commit e36a755

Please sign in to comment.