mirror of https://github.com/halo-dev/halo
chore: cleanup unused index for notification (#6481)
#### What type of PR is this? /kind cleanup /area core /milestone 2.19.x #### What this PR does / why we need it: 清理没有用到的索引 #### Does this PR introduce a user-facing change? ```release-note None ```pull/6484/head^2
parent
a938712739
commit
7ba5fc671f
|
@ -6759,14 +6759,6 @@
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Keyword",
|
|
||||||
"in": "query",
|
|
||||||
"name": "keyword",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
|
|
@ -533,16 +533,6 @@ public class SchemeInitializer implements ApplicationListener<ApplicationContext
|
||||||
.setIndexFunc(simpleAttribute(Notification.class,
|
.setIndexFunc(simpleAttribute(Notification.class,
|
||||||
notification -> notification.getSpec().getRecipient()))
|
notification -> notification.getSpec().getRecipient()))
|
||||||
);
|
);
|
||||||
indexSpecs.add(new IndexSpec()
|
|
||||||
.setName("spec.title")
|
|
||||||
.setIndexFunc(simpleAttribute(Notification.class,
|
|
||||||
notification -> notification.getSpec().getTitle()))
|
|
||||||
);
|
|
||||||
indexSpecs.add(new IndexSpec()
|
|
||||||
.setName("spec.rawContent")
|
|
||||||
.setIndexFunc(simpleAttribute(Notification.class,
|
|
||||||
notification -> notification.getSpec().getRawContent()))
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,13 @@
|
||||||
package run.halo.app.notification;
|
package run.halo.app.notification;
|
||||||
|
|
||||||
import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder;
|
|
||||||
import static run.halo.app.extension.index.query.QueryFactory.and;
|
import static run.halo.app.extension.index.query.QueryFactory.and;
|
||||||
import static run.halo.app.extension.index.query.QueryFactory.contains;
|
|
||||||
import static run.halo.app.extension.index.query.QueryFactory.equal;
|
import static run.halo.app.extension.index.query.QueryFactory.equal;
|
||||||
import static run.halo.app.extension.index.query.QueryFactory.or;
|
|
||||||
import static run.halo.app.extension.router.QueryParamBuildUtil.sortParameter;
|
|
||||||
import static run.halo.app.extension.router.selector.SelectorUtil.labelAndFieldSelectorToListOptions;
|
import static run.halo.app.extension.router.selector.SelectorUtil.labelAndFieldSelectorToListOptions;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
|
||||||
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springdoc.core.fn.builders.operation.Builder;
|
|
||||||
import org.springframework.data.domain.Sort;
|
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
import org.springframework.web.server.ServerWebExchange;
|
||||||
import run.halo.app.core.extension.endpoint.SortResolver;
|
|
||||||
import run.halo.app.extension.ListOptions;
|
import run.halo.app.extension.ListOptions;
|
||||||
import run.halo.app.extension.PageRequest;
|
import run.halo.app.extension.router.SortableRequest;
|
||||||
import run.halo.app.extension.PageRequestImpl;
|
|
||||||
import run.halo.app.extension.router.IListRequest;
|
|
||||||
import run.halo.app.extension.router.selector.FieldSelector;
|
import run.halo.app.extension.router.selector.FieldSelector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,72 +16,27 @@ import run.halo.app.extension.router.selector.FieldSelector;
|
||||||
* @author guqing
|
* @author guqing
|
||||||
* @since 2.10.0
|
* @since 2.10.0
|
||||||
*/
|
*/
|
||||||
public class UserNotificationQuery extends IListRequest.QueryListRequest {
|
public class UserNotificationQuery extends SortableRequest {
|
||||||
|
|
||||||
private final ServerWebExchange exchange;
|
|
||||||
|
|
||||||
private final String username;
|
private final String username;
|
||||||
|
|
||||||
public UserNotificationQuery(ServerWebExchange exchange, String username) {
|
public UserNotificationQuery(ServerWebExchange exchange, String username) {
|
||||||
super(exchange.getRequest().getQueryParams());
|
super(exchange);
|
||||||
this.exchange = exchange;
|
|
||||||
this.username = username;
|
this.username = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public String getKeyword() {
|
|
||||||
return StringUtils.defaultIfBlank(queryParams.getFirst("keyword"), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ArraySchema(uniqueItems = true,
|
|
||||||
arraySchema = @Schema(name = "sort",
|
|
||||||
description = "Sort property and direction of the list result. Supported fields: "
|
|
||||||
+ "metadata.creationTimestamp"),
|
|
||||||
schema = @Schema(description = "like field,asc or field,desc",
|
|
||||||
implementation = String.class,
|
|
||||||
example = "creationTimestamp,desc"))
|
|
||||||
public Sort getSort() {
|
|
||||||
var sort = SortResolver.defaultInstance.resolve(exchange);
|
|
||||||
return sort.and(Sort.by(
|
|
||||||
Sort.Order.desc("metadata.creationTimestamp"),
|
|
||||||
Sort.Order.desc("metadata.name"))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build a list options from the query object.
|
* Build a list options from the query object.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ListOptions toListOptions() {
|
public ListOptions toListOptions() {
|
||||||
var listOptions =
|
var listOptions =
|
||||||
labelAndFieldSelectorToListOptions(getLabelSelector(), getFieldSelector());
|
labelAndFieldSelectorToListOptions(getLabelSelector(), getFieldSelector());
|
||||||
var filedQuery = listOptions.getFieldSelector().query();
|
var filedQuery = listOptions.getFieldSelector().query();
|
||||||
if (StringUtils.isNotBlank(getKeyword())) {
|
|
||||||
filedQuery = and(filedQuery,
|
|
||||||
or(
|
|
||||||
contains("spec.title", getKeyword()),
|
|
||||||
contains("spec.rawContent", getKeyword())
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotBlank(username)) {
|
if (StringUtils.isNotBlank(username)) {
|
||||||
filedQuery = and(filedQuery, equal("spec.recipient", username));
|
filedQuery = and(filedQuery, equal("spec.recipient", username));
|
||||||
}
|
}
|
||||||
listOptions.setFieldSelector(FieldSelector.of(filedQuery));
|
listOptions.setFieldSelector(FieldSelector.of(filedQuery));
|
||||||
return listOptions;
|
return listOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PageRequest toPageRequest() {
|
|
||||||
return PageRequestImpl.of(getPage(), getSize(), getSort());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void buildParameters(Builder builder) {
|
|
||||||
IListRequest.buildParameters(builder);
|
|
||||||
builder.parameter(sortParameter())
|
|
||||||
.parameter(parameterBuilder()
|
|
||||||
.in(ParameterIn.QUERY)
|
|
||||||
.name("keyword")
|
|
||||||
.description("Keyword")
|
|
||||||
.implementation(String.class)
|
|
||||||
.required(false));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,11 +131,10 @@ export const NotificationV1alpha1UcApiAxiosParamCreator = function (configuratio
|
||||||
* @param {Array<string>} [labelSelector] Label selector. e.g.: hidden!=true
|
* @param {Array<string>} [labelSelector] Label selector. e.g.: hidden!=true
|
||||||
* @param {Array<string>} [fieldSelector] Field selector. e.g.: metadata.name==halo
|
* @param {Array<string>} [fieldSelector] Field selector. e.g.: metadata.name==halo
|
||||||
* @param {Array<string>} [sort] Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.
|
* @param {Array<string>} [sort] Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.
|
||||||
* @param {string} [keyword] Keyword
|
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
listUserNotifications: async (username: string, page?: number, size?: number, labelSelector?: Array<string>, fieldSelector?: Array<string>, sort?: Array<string>, keyword?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
listUserNotifications: async (username: string, page?: number, size?: number, labelSelector?: Array<string>, fieldSelector?: Array<string>, sort?: Array<string>, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||||
// verify required parameter 'username' is not null or undefined
|
// verify required parameter 'username' is not null or undefined
|
||||||
assertParamExists('listUserNotifications', 'username', username)
|
assertParamExists('listUserNotifications', 'username', username)
|
||||||
const localVarPath = `/apis/api.notification.halo.run/v1alpha1/userspaces/{username}/notifications`
|
const localVarPath = `/apis/api.notification.halo.run/v1alpha1/userspaces/{username}/notifications`
|
||||||
|
@ -179,10 +178,6 @@ export const NotificationV1alpha1UcApiAxiosParamCreator = function (configuratio
|
||||||
localVarQueryParameter['sort'] = sort;
|
localVarQueryParameter['sort'] = sort;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyword !== undefined) {
|
|
||||||
localVarQueryParameter['keyword'] = keyword;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
||||||
|
@ -374,12 +369,11 @@ export const NotificationV1alpha1UcApiFp = function(configuration?: Configuratio
|
||||||
* @param {Array<string>} [labelSelector] Label selector. e.g.: hidden!=true
|
* @param {Array<string>} [labelSelector] Label selector. e.g.: hidden!=true
|
||||||
* @param {Array<string>} [fieldSelector] Field selector. e.g.: metadata.name==halo
|
* @param {Array<string>} [fieldSelector] Field selector. e.g.: metadata.name==halo
|
||||||
* @param {Array<string>} [sort] Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.
|
* @param {Array<string>} [sort] Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.
|
||||||
* @param {string} [keyword] Keyword
|
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
async listUserNotifications(username: string, page?: number, size?: number, labelSelector?: Array<string>, fieldSelector?: Array<string>, sort?: Array<string>, keyword?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<NotificationList>> {
|
async listUserNotifications(username: string, page?: number, size?: number, labelSelector?: Array<string>, fieldSelector?: Array<string>, sort?: Array<string>, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<NotificationList>> {
|
||||||
const localVarAxiosArgs = await localVarAxiosParamCreator.listUserNotifications(username, page, size, labelSelector, fieldSelector, sort, keyword, options);
|
const localVarAxiosArgs = await localVarAxiosParamCreator.listUserNotifications(username, page, size, labelSelector, fieldSelector, sort, options);
|
||||||
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
||||||
const localVarOperationServerBasePath = operationServerMap['NotificationV1alpha1UcApi.listUserNotifications']?.[localVarOperationServerIndex]?.url;
|
const localVarOperationServerBasePath = operationServerMap['NotificationV1alpha1UcApi.listUserNotifications']?.[localVarOperationServerIndex]?.url;
|
||||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||||
|
@ -458,7 +452,7 @@ export const NotificationV1alpha1UcApiFactory = function (configuration?: Config
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
listUserNotifications(requestParameters: NotificationV1alpha1UcApiListUserNotificationsRequest, options?: RawAxiosRequestConfig): AxiosPromise<NotificationList> {
|
listUserNotifications(requestParameters: NotificationV1alpha1UcApiListUserNotificationsRequest, options?: RawAxiosRequestConfig): AxiosPromise<NotificationList> {
|
||||||
return localVarFp.listUserNotifications(requestParameters.username, requestParameters.page, requestParameters.size, requestParameters.labelSelector, requestParameters.fieldSelector, requestParameters.sort, requestParameters.keyword, options).then((request) => request(axios, basePath));
|
return localVarFp.listUserNotifications(requestParameters.username, requestParameters.page, requestParameters.size, requestParameters.labelSelector, requestParameters.fieldSelector, requestParameters.sort, options).then((request) => request(axios, basePath));
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Mark the specified notification as read.
|
* Mark the specified notification as read.
|
||||||
|
@ -572,13 +566,6 @@ export interface NotificationV1alpha1UcApiListUserNotificationsRequest {
|
||||||
* @memberof NotificationV1alpha1UcApiListUserNotifications
|
* @memberof NotificationV1alpha1UcApiListUserNotifications
|
||||||
*/
|
*/
|
||||||
readonly sort?: Array<string>
|
readonly sort?: Array<string>
|
||||||
|
|
||||||
/**
|
|
||||||
* Keyword
|
|
||||||
* @type {string}
|
|
||||||
* @memberof NotificationV1alpha1UcApiListUserNotifications
|
|
||||||
*/
|
|
||||||
readonly keyword?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -681,7 +668,7 @@ export class NotificationV1alpha1UcApi extends BaseAPI {
|
||||||
* @memberof NotificationV1alpha1UcApi
|
* @memberof NotificationV1alpha1UcApi
|
||||||
*/
|
*/
|
||||||
public listUserNotifications(requestParameters: NotificationV1alpha1UcApiListUserNotificationsRequest, options?: RawAxiosRequestConfig) {
|
public listUserNotifications(requestParameters: NotificationV1alpha1UcApiListUserNotificationsRequest, options?: RawAxiosRequestConfig) {
|
||||||
return NotificationV1alpha1UcApiFp(this.configuration).listUserNotifications(requestParameters.username, requestParameters.page, requestParameters.size, requestParameters.labelSelector, requestParameters.fieldSelector, requestParameters.sort, requestParameters.keyword, options).then((request) => request(this.axios, this.basePath));
|
return NotificationV1alpha1UcApiFp(this.configuration).listUserNotifications(requestParameters.username, requestParameters.page, requestParameters.size, requestParameters.labelSelector, requestParameters.fieldSelector, requestParameters.sort, options).then((request) => request(this.axios, this.basePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue