**本番 DB のバックアップをかならずすること** Reviewed-on: #420 Co-authored-by: miteruzo <miteruzo@naver.com>
このコミットはプルリクエスト #420 でマージされました。
このコミットが含まれているのは:
@@ -116,4 +116,25 @@ describe ('posts API functions', () => {
|
||||
{ params: { page: 2, limit: 50 } },
|
||||
)
|
||||
})
|
||||
|
||||
it ('maps an explicit external tag history filter to external_tag', async () => {
|
||||
api.apiGet.mockResolvedValueOnce ({ versions: [], count: 0 })
|
||||
|
||||
await fetchPostChanges ({
|
||||
externalTag: '7',
|
||||
page: 2,
|
||||
limit: 50,
|
||||
})
|
||||
|
||||
expect (api.apiGet).toHaveBeenCalledWith (
|
||||
'/posts/versions',
|
||||
{
|
||||
params: {
|
||||
external_tag: '7',
|
||||
page: 2,
|
||||
limit: 50,
|
||||
},
|
||||
},
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -28,15 +28,18 @@ export const fetchPost = async (id: string): Promise<Post> => await apiGet (`/po
|
||||
|
||||
|
||||
export const fetchPostChanges = async (
|
||||
{ post, tag, page, limit }: {
|
||||
post?: string
|
||||
tag?: string
|
||||
page: number
|
||||
limit: number }): Promise<{
|
||||
{ post, tag, externalTag, page, limit }: {
|
||||
post?: string
|
||||
tag?: string
|
||||
externalTag?: string
|
||||
page: number
|
||||
limit: number }): Promise<{
|
||||
versions: PostVersion[]
|
||||
count: number }> =>
|
||||
await apiGet ('/posts/versions', { params: { ...(post && { post }),
|
||||
...(tag && { tag }),
|
||||
...(externalTag && {
|
||||
external_tag: externalTag }),
|
||||
page, limit } })
|
||||
|
||||
|
||||
|
||||
@@ -137,4 +137,19 @@ describe ('prefetchForURL', () => {
|
||||
expect (tagsApi.fetchTags).not.toHaveBeenCalled ()
|
||||
expect (wikiApi.fetchWikiPages).not.toHaveBeenCalled ()
|
||||
})
|
||||
|
||||
it ('prefetches external tag post history without treating it as an internal tag', async () => {
|
||||
await prefetchForURL (
|
||||
qc (),
|
||||
'http://localhost/posts/changes?external_tag=12&page=2&limit=50',
|
||||
)
|
||||
|
||||
expect (postsApi.fetchPostChanges).toHaveBeenCalledWith ({
|
||||
externalTag: '12',
|
||||
page: 2,
|
||||
limit: 50,
|
||||
})
|
||||
|
||||
expect (tagsApi.fetchTag).not.toHaveBeenCalled ()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -128,6 +128,7 @@ const prefetchPostShow: Prefetcher = async (qc, url) => {
|
||||
const prefetchPostChanges: Prefetcher = async (qc, url) => {
|
||||
const id = url.searchParams.get ('id')
|
||||
const tag = url.searchParams.get ('tag')
|
||||
const externalTag = url.searchParams.get ('external_tag')
|
||||
const page = Number (url.searchParams.get ('page') || 1)
|
||||
const limit = Number (url.searchParams.get ('limit') || 20)
|
||||
|
||||
@@ -141,9 +142,11 @@ const prefetchPostChanges: Prefetcher = async (qc, url) => {
|
||||
await qc.prefetchQuery ({
|
||||
queryKey: postsKeys.changes ({ ...(id && { id }),
|
||||
...(tag && { tag }),
|
||||
...(externalTag && { externalTag }),
|
||||
page, limit }),
|
||||
queryFn: () => fetchPostChanges ({ ...(id && { id }),
|
||||
...(tag && { tag }),
|
||||
...(externalTag && { externalTag }),
|
||||
page, limit }) })
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,11 @@ export const postsKeys = {
|
||||
index: (p: FetchPostsParams) => ['posts', 'index', p] as const,
|
||||
show: (id: string) => ['posts', id] as const,
|
||||
related: (id: string) => ['related', id] as const,
|
||||
changes: (p: { post?: string; tag?: string; page: number; limit: number }) =>
|
||||
changes: (p: { post?: string
|
||||
tag?: string
|
||||
externalTag?: string
|
||||
page: number
|
||||
limit: number }) =>
|
||||
['posts', 'changes', p] as const }
|
||||
|
||||
export const gekanatorKeys = {
|
||||
@@ -26,6 +30,7 @@ export const tagsKeys = {
|
||||
index: (p: FetchTagsParams) => ['tags', 'index', p] as const,
|
||||
nicoRoot: ['tags', 'nico'] as const,
|
||||
nicoIndex: (p: FetchNicoTagsParams) => ['tags', 'nico', 'index', p] as const,
|
||||
externalShow: (id: string) => ['tags', 'nico', id] as const,
|
||||
show: (name: string) => ['tags', name] as const,
|
||||
changes: (p: { id?: string; page: number; limit: number }) =>
|
||||
['tags', 'changes', p] as const,
|
||||
|
||||
@@ -53,6 +53,18 @@ export const fetchTag = async (id: string): Promise<Tag | null> => {
|
||||
}
|
||||
|
||||
|
||||
export const fetchExternalTag = async (id: string): Promise<Tag | null> => {
|
||||
try
|
||||
{
|
||||
return await apiGet (`/tags/nico/${ id }`)
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const fetchTagByName = async (name: string): Promise<Tag | null> => {
|
||||
try
|
||||
{
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする