This commit is contained in:
おさむのひと 2025-12-27 14:45:32 +09:00 committed by GitHub
commit 83999739b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 63 additions and 1 deletions

View File

@ -1,7 +1,7 @@
## Unreleased
### General
-
- Feat: ノート検索で投稿日時の期間を条件に加えられるように(#16035)
### Client
- Fix: ドライブクリーナーでファイルを削除しても画面に反映されない問題を修正 #16061

View File

@ -3309,6 +3309,8 @@ _search:
pleaseEnterServerHost: "サーバーのホストを入力してください"
pleaseSelectUser: "ユーザーを選択してください"
serverHostPlaceholder: "例: misskey.example.com"
postFrom: "投稿日時from"
postTo: "投稿日時to"
_serverSetupWizard:
installCompleted: "Misskeyのインストールが完了しました"

View File

@ -38,6 +38,8 @@ export type SearchOpts = {
userId?: MiNote['userId'] | null;
channelId?: MiNote['channelId'] | null;
host?: string | null;
rangeStartAt?: number | null;
rangeEndAt?: number | null;
};
export type SearchPagination = {
@ -233,6 +235,16 @@ export class SearchService {
}
}
if (opts.rangeStartAt) {
const date = this.idService.gen(opts.rangeStartAt);
query.andWhere('note.id >= :rangeStartAt', { rangeStartAt: date });
}
if (opts.rangeEndAt) {
const date = this.idService.gen(opts.rangeEndAt);
query.andWhere('note.id <= :rangeEndAt', { rangeEndAt: date });
}
this.queryService.generateVisibilityQuery(query, me);
this.queryService.generateBaseNoteFilteringQuery(query, me);
@ -259,11 +271,21 @@ export class SearchService {
k: 'createdAt',
v: this.idService.parse(pagination.untilId).date.getTime(),
});
if (opts.rangeEndAt) filter.qs.push({
op: '<=',
k: 'createdAt',
v: opts.rangeEndAt,
});
if (pagination.sinceId) filter.qs.push({
op: '>',
k: 'createdAt',
v: this.idService.parse(pagination.sinceId).date.getTime(),
});
if (opts.rangeStartAt) filter.qs.push({
op: '>=',
k: 'createdAt',
v: opts.rangeStartAt,
});
if (opts.userId) filter.qs.push({ op: '=', k: 'userId', v: opts.userId });
if (opts.channelId) filter.qs.push({ op: '=', k: 'channelId', v: opts.channelId });
if (opts.host) {

View File

@ -39,6 +39,8 @@ export const paramDef = {
type: 'object',
properties: {
query: { type: 'string' },
rangeStartAt: { type: 'integer', nullable: true },
rangeEndAt: { type: 'integer', nullable: true },
sinceId: { type: 'string', format: 'misskey:id' },
untilId: { type: 'string', format: 'misskey:id' },
sinceDate: { type: 'integer' },
@ -78,6 +80,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
userId: ps.userId,
channelId: ps.channelId,
host: ps.host,
rangeStartAt: ps.rangeStartAt,
rangeEndAt: ps.rangeEndAt,
}, {
untilId: untilId,
sinceId: sinceId,

View File

@ -19,6 +19,15 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #header>{{ i18n.ts.options }}</template>
<div class="_gaps_m">
<div style="display: flex; gap: 8px;">
<MkInput v-model="rangeStartAt" type="datetime-local">
<template #label>{{ i18n.ts._search.postFrom }}</template>
</MkInput>
<MkInput v-model="rangeEndAt" type="datetime-local">
<template #label>{{ i18n.ts._search.postTo }}</template>
</MkInput>
</div>
<MkRadios v-model="searchScope">
<option v-if="instance.federation !== 'none' && noteSearchableScope === 'global'" value="all">{{ i18n.ts._search.searchScopeAll }}</option>
<option value="local">{{ instance.federation === 'none' ? i18n.ts._search.searchScopeAll : i18n.ts._search.searchScopeLocal }}</option>
@ -148,6 +157,8 @@ const paginator = shallowRef<Paginator<'notes/search'> | null>(null);
const searchQuery = ref(toRef(props, 'query').value);
const hostInput = ref(toRef(props, 'host').value);
const rangeStartAt = ref<string | null>(null);
const rangeEndAt = ref<string | null>(null);
const user = shallowRef<Misskey.entities.UserDetailed | null>(null);
@ -188,6 +199,8 @@ type SearchParams = {
readonly query: string;
readonly host?: string;
readonly userId?: string;
readonly rangeStartAt?: number | null;
readonly rangeEndAt?: number | null;
};
const fixHostIfLocal = (target: string | null | undefined) => {
@ -195,6 +208,13 @@ const fixHostIfLocal = (target: string | null | undefined) => {
return target;
};
const searchRange = () => {
return {
rangeStartAt: rangeStartAt.value ? new Date(rangeStartAt.value).getTime() : null,
rangeEndAt: rangeEndAt.value ? new Date(rangeEndAt.value).getTime() : null,
};
};
const searchParams = computed<SearchParams | null>(() => {
const trimmedQuery = searchQuery.value.trim();
if (!trimmedQuery) return null;
@ -205,6 +225,7 @@ const searchParams = computed<SearchParams | null>(() => {
query: trimmedQuery,
host: fixHostIfLocal(user.value.host),
userId: user.value.id,
...searchRange(),
};
}
@ -219,6 +240,7 @@ const searchParams = computed<SearchParams | null>(() => {
return {
query: trimmedQuery,
host: fixHostIfLocal(trimmedHost),
...searchRange(),
};
}
@ -226,11 +248,13 @@ const searchParams = computed<SearchParams | null>(() => {
return {
query: trimmedQuery,
host: '.',
...searchRange(),
};
}
return {
query: trimmedQuery,
...searchRange(),
};
});

View File

@ -12375,6 +12375,14 @@ export interface Locale extends ILocale {
* : misskey.example.com
*/
"serverHostPlaceholder": string;
/**
* 稿from
*/
"postFrom": string;
/**
* 稿to
*/
"postTo": string;
};
"_serverSetupWizard": {
/**

View File

@ -30780,6 +30780,8 @@ export interface operations {
content: {
'application/json': {
query: string;
rangeStartAt?: number | null;
rangeEndAt?: number | null;
/** Format: misskey:id */
sinceId?: string;
/** Format: misskey:id */