릴리스: v1.4.25 topic 응답/요청 키 정리

This commit is contained in:
2026-04-02 20:51:03 +09:00
parent 257d50f9c5
commit 932b4e35a7
20 changed files with 188 additions and 199 deletions

View File

@@ -87,7 +87,6 @@ function mapGameItemRow(row) {
return {
id: row.id,
topicId: row.topic_id,
gameId: row.topic_id,
src: row.src,
label: row.label,
displayOrder: row.display_order == null ? null : Number(row.display_order),
@@ -137,8 +136,6 @@ function mapTierListRow(row) {
authorAvatarSrc: row.avatar_src || '',
topicId: row.topic_id,
topicName: row.topic_name || '',
gameId: row.topic_id,
gameName: row.topic_name || '',
title: row.title,
thumbnailSrc: row.thumbnail_src || '',
description: row.description || '',
@@ -167,15 +164,11 @@ function mapTemplateRequestRow(row) {
sourceTierListId: row.source_tierlist_id || '',
sourceTopicId: row.source_topic_id,
sourceTopicName: row.source_topic_name || '',
sourceGameId: row.source_topic_id,
sourceGameName: row.source_topic_name || '',
sourceTierListTitle: row.title_snapshot || '',
sourceDescription: row.description_snapshot || '',
thumbnailSrc: row.thumbnail_src_snapshot || '',
targetTopicId: row.target_topic_id || '',
targetTopicName: row.target_topic_name || '',
targetGameId: row.target_topic_id || '',
targetGameName: row.target_topic_name || '',
status: row.status,
items: parseJson(row.items_json, []),
snapshotGroups: parseJson(row.groups_json, []),
@@ -1347,15 +1340,14 @@ async function clearImageOptimizationJobs({ month } = {}) {
const result = await query('DELETE FROM image_optimization_jobs')
return Number(result.affectedRows || 0)
}
async function createTopicItem({ id, topicId, gameId = topicId, src, label }) {
async function createTopicItem({ id, topicId, src, label }) {
const createdAt = now()
const resolvedTopicId = topicId || gameId
const minOrderRows = await query('SELECT MIN(display_order) AS min_display_order FROM topic_items WHERE topic_id = ?', [resolvedTopicId])
const minOrderRows = await query('SELECT MIN(display_order) AS min_display_order FROM topic_items WHERE topic_id = ?', [topicId])
const nextDisplayOrder =
minOrderRows[0]?.min_display_order == null ? 0 : Number(minOrderRows[0].min_display_order) - 1
await query('INSERT INTO topic_items (id, topic_id, src, label, display_order, created_at) VALUES (?, ?, ?, ?, ?, ?)', [
id,
resolvedTopicId,
topicId,
src,
label,
nextDisplayOrder,
@@ -1456,8 +1448,8 @@ async function updateTopicDisplayOrder(topicIds) {
await query('UPDATE topics SET display_rank = NULL WHERE id <> ?', [FREEFORM_TOPIC_ID])
await Promise.all(
normalizedIds.map((gameId, index) =>
query('UPDATE topics SET display_rank = ? WHERE id = ? AND id <> ?', [index + 1, gameId, FREEFORM_TOPIC_ID])
normalizedIds.map((topicId, index) =>
query('UPDATE topics SET display_rank = ? WHERE id = ? AND id <> ?', [index + 1, topicId, FREEFORM_TOPIC_ID])
)
)
@@ -1679,8 +1671,8 @@ async function listCustomItems({ queryText = '', page = 1, limit = 50, filterMod
sourceType: 'template',
sourceLabel: '관리자 템플릿',
canDelete: true,
sourceGameId: '',
sourceGameName: '',
sourceTopicId: '',
sourceTopicName: '',
isAssetLibraryItem: true,
}))
@@ -1697,8 +1689,8 @@ async function listCustomItems({ queryText = '', page = 1, limit = 50, filterMod
sourceType: 'template',
sourceLabel: '관리자 템플릿',
canDelete: true,
sourceGameId: row.topic_id,
sourceGameName: row.topic_name || row.topic_id,
sourceTopicId: row.topic_id,
sourceTopicName: row.topic_name || row.topic_id,
}))
const baseItems = [...customItems, ...templateItems, ...assetLibraryItems]
@@ -1743,8 +1735,8 @@ async function listCustomItems({ queryText = '', page = 1, limit = 50, filterMod
sourceType: entry.sourceType,
ownerName: entry.ownerName,
createdAt: entry.createdAt,
sourceGameId: entry.sourceGameId || '',
sourceGameName: entry.sourceGameName || '',
sourceTopicId: entry.sourceTopicId || '',
sourceTopicName: entry.sourceTopicName || '',
usageCount: entry.usageCount || 0,
linkedGames: entry.linkedGames || [],
isAssetLibraryItem: !!entry.isAssetLibraryItem,
@@ -1902,7 +1894,6 @@ async function listPublicTierLists(topicId, currentUserId = '', queryText = '')
const tierLists = rows.map((row) => ({
id: row.id,
topicId: row.topic_id,
gameId: row.topic_id,
title: row.title,
thumbnailSrc: row.thumbnail_src || '',
createdAt: Number(row.created_at),
@@ -2011,7 +2002,6 @@ async function listUserTierLists(userId) {
const tierLists = rows.map((row) => ({
id: row.id,
topicId: row.topic_id,
gameId: row.topic_id,
title: row.title,
thumbnailSrc: row.thumbnail_src || '',
createdAt: Number(row.created_at),
@@ -2057,11 +2047,11 @@ function getAutoThumbnailSrc(groups = [], pool = []) {
return fallbackItem?.src || ''
}
async function listAdminTierLists({ queryText = '', gameId = '', topicId = '', page = 1, limit = 50, currentUserId = '' } = {}) {
async function listAdminTierLists({ queryText = '', topicId = '', page = 1, limit = 50, currentUserId = '' } = {}) {
const normalizedLimit = Math.min(Math.max(Number(limit) || 50, 1), 200)
const normalizedPage = Math.max(Number(page) || 1, 1)
const hasQuery = !!(queryText || '').trim()
const resolvedTopicId = (topicId || gameId || '').trim()
const resolvedTopicId = (topicId || '').trim()
const hasGameId = !!resolvedTopicId
const search = `%${(queryText || '').trim()}%`
const whereParts = []
@@ -2144,9 +2134,9 @@ async function listAdminTierLists({ queryText = '', gameId = '', topicId = '', p
}
}
async function summarizeAdminTierLists({ queryText = '', gameId = '', topicId = '' } = {}) {
async function summarizeAdminTierLists({ queryText = '', topicId = '' } = {}) {
const hasQuery = !!(queryText || '').trim()
const resolvedTopicId = (topicId || gameId || '').trim()
const resolvedTopicId = (topicId || '').trim()
const hasGameId = !!resolvedTopicId
const search = `%${(queryText || '').trim()}%`
const whereParts = []
@@ -2245,10 +2235,8 @@ async function createTemplateRequest({
type,
requesterId,
sourceTierListId = '',
sourceGameId,
targetGameId = '',
sourceTopicId = sourceGameId,
targetTopicId = targetGameId,
sourceTopicId,
targetTopicId = '',
title,
description = '',
thumbnailSrc = '',
@@ -2401,8 +2389,8 @@ async function updateTemplateRequestStatus({ id, status }) {
return findTemplateRequestById(id)
}
async function updateTemplateRequestTargetGame({ id, targetGameId }) {
await query('UPDATE template_requests SET target_topic_id = ?, updated_at = ? WHERE id = ?', [targetGameId || '', now(), id])
async function updateTemplateRequestTargetTopic({ id, targetTopicId }) {
await query('UPDATE template_requests SET target_topic_id = ?, updated_at = ? WHERE id = ?', [targetTopicId || '', now(), id])
return findTemplateRequestById(id)
}
@@ -2452,8 +2440,7 @@ async function deleteCustomItems(ids) {
async function saveTierList({
id,
authorId,
gameId,
topicId = gameId,
topicId,
title,
thumbnailSrc = '',
description,
@@ -2504,8 +2491,7 @@ async function duplicateTierListForUser({ tierList, targetUserId }) {
return saveTierList({
id: duplicateId,
authorId: targetUserId,
gameId: tierList.topicId || tierList.gameId,
topicId: tierList.topicId || tierList.gameId,
topicId: tierList.topicId,
title: copyTitle,
thumbnailSrc: tierList.thumbnailSrc || '',
description: tierList.description || '',
@@ -2528,14 +2514,12 @@ async function unfavoriteTierList({ userId, tierListId }) {
await query('DELETE FROM favorite_tierlists WHERE user_id = ? AND tierlist_id = ?', [userId, tierListId])
}
async function favoriteTopic({ userId, topicId, gameId = topicId }) {
const resolvedTopicId = topicId || gameId
await query('INSERT IGNORE INTO favorite_topics (user_id, topic_id, created_at) VALUES (?, ?, ?)', [userId, resolvedTopicId, now()])
async function favoriteTopic({ userId, topicId }) {
await query('INSERT IGNORE INTO favorite_topics (user_id, topic_id, created_at) VALUES (?, ?, ?)', [userId, topicId, now()])
}
async function unfavoriteTopic({ userId, topicId, gameId = topicId }) {
const resolvedTopicId = topicId || gameId
await query('DELETE FROM favorite_topics WHERE user_id = ? AND topic_id = ?', [userId, resolvedTopicId])
async function unfavoriteTopic({ userId, topicId }) {
await query('DELETE FROM favorite_topics WHERE user_id = ? AND topic_id = ?', [userId, topicId])
}
const favoriteGame = favoriteTopic
@@ -2629,5 +2613,6 @@ module.exports = {
findTemplateRequestById,
listAdminTemplateRequests,
updateTemplateRequestStatus,
updateTemplateRequestTargetGame,
updateTemplateRequestTargetTopic,
updateTemplateRequestTargetGame: updateTemplateRequestTargetTopic,
}