mirror of
https://fast.feibisi.com/https://github.com/parcelvoy/platform.git
synced 2025-08-28 11:46:02 +08:00
Allow list total recalculation (#657)
This commit is contained in:
parent
b9c26e3204
commit
75706bb63f
7 changed files with 37 additions and 3 deletions
|
@ -7,6 +7,7 @@ import { SearchSchema } from '../core/searchParams'
|
|||
import { ProjectState } from '../auth/AuthMiddleware'
|
||||
import parse from '../storage/FileStream'
|
||||
import { projectRoleMiddleware } from '../projects/ProjectService'
|
||||
import ListStatsJob from './ListStatsJob'
|
||||
|
||||
const router = new Router<
|
||||
ProjectState & { list?: List }
|
||||
|
@ -201,4 +202,13 @@ router.post('/:listId/users', async ctx => {
|
|||
ctx.status = 204
|
||||
})
|
||||
|
||||
router.post('/:listId/recount', async ctx => {
|
||||
await ListStatsJob.from(
|
||||
ctx.state.list!.id,
|
||||
ctx.state.project.id,
|
||||
true,
|
||||
).queue()
|
||||
ctx.status = 204
|
||||
})
|
||||
|
||||
export default router
|
||||
|
|
|
@ -40,7 +40,7 @@ export default class ListEvaluateUserJob extends Job {
|
|||
await evaluate()
|
||||
} finally {
|
||||
const cacheKey = CacheKeys.populationProgress(list)
|
||||
const count = await cacheIncr(App.main.redis, cacheKey, 1, 300)
|
||||
const count = await cacheIncr(App.main.redis, cacheKey, 1, 86400)
|
||||
if (count >= totalCount) {
|
||||
await cleanupList(list)
|
||||
}
|
||||
|
|
|
@ -247,6 +247,7 @@
|
|||
"rebuild_path_suggestions_desc": "Would you like to recreate all of the event and user data autocomplete paths used for creating rules?",
|
||||
"rebuild_path_suggestions_success": "Path suggestions are rebuilding. This might take a few minutes depending on how many users and events you have.",
|
||||
"recently_viewed": "Recently Viewed",
|
||||
"recount": "Recount",
|
||||
"remove": "Remove",
|
||||
"remove_locale_warning": "Are you sure you want to delete this locale? The template cannot be recovered.",
|
||||
"reply_to": "Reply To",
|
||||
|
|
|
@ -247,6 +247,7 @@
|
|||
"rebuild_path_suggestions_desc": "¿Le gustaría recrear todas las rutas de autocompletado de datos de eventos y usuarios utilizadas para crear reglas?",
|
||||
"rebuild_path_suggestions_success": "Las sugerencias de ruta se están reconstruyendo. Esto puede tardar unos minutos dependiendo de cuántos usuarios y eventos tengas.",
|
||||
"recently_viewed": "Visto Recientemente",
|
||||
"recount": "Contar Totales",
|
||||
"remove": "Eliminar",
|
||||
"remove_locale_warning": "¿Está seguro de que desea eliminar esta configuración regional? La plantilla no se puede recuperar.",
|
||||
"reply_to": "Responder a",
|
||||
|
|
|
@ -238,6 +238,7 @@
|
|||
"rebuild_path_suggestions_desc": "您想重新创建用于创建规则的所有事件和用户数据自动完成路径吗?",
|
||||
"rebuild_path_suggestions_success": "正在重建路径建议。这可能需要几分钟,具体取决于您有多少用户和事件。",
|
||||
"recently_viewed": "最近浏览",
|
||||
"recount": "计算总数",
|
||||
"remove": "移除",
|
||||
"remove_locale_warning": "您确定要删除此地区吗?模板无法恢复。",
|
||||
"reply_to": "回复至",
|
||||
|
|
|
@ -240,6 +240,9 @@ const api = {
|
|||
duplicate: async (projectId: number | string, listId: number | string) => await client
|
||||
.post<List>(`${projectUrl(projectId)}/lists/${listId}/duplicate`)
|
||||
.then(r => r.data),
|
||||
recount: async (projectId: number | string, listId: number | string) => await client
|
||||
.post<List>(`${projectUrl(projectId)}/lists/${listId}/recount`)
|
||||
.then(r => r.data),
|
||||
},
|
||||
|
||||
projectAdmins: {
|
||||
|
|
|
@ -16,10 +16,10 @@ import { snakeToTitle } from '../../utils'
|
|||
import UploadField from '../../ui/form/UploadField'
|
||||
import { SearchTable, useSearchTableState } from '../../ui/SearchTable'
|
||||
import { useRoute } from '../router'
|
||||
import { EditIcon, SendIcon, UploadIcon } from '../../ui/icons'
|
||||
import { ArchiveIcon, EditIcon, RestartIcon, SendIcon, UploadIcon } from '../../ui/icons'
|
||||
import { TagPicker } from '../settings/TagPicker'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Alert } from '../../ui'
|
||||
import { Alert, Menu, MenuItem } from '../../ui'
|
||||
import { useBlocker } from 'react-router-dom'
|
||||
|
||||
interface RuleSectionProps {
|
||||
|
@ -109,6 +109,16 @@ export default function ListDetail() {
|
|||
await state.reload()
|
||||
}
|
||||
|
||||
const handleRecountList = async () => {
|
||||
await api.lists.recount(project.id, list.id)
|
||||
window.location.reload()
|
||||
}
|
||||
|
||||
const handleArchiveList = async () => {
|
||||
await api.lists.delete(project.id, list.id)
|
||||
window.location.href = `/projects/${project.id}/lists`
|
||||
}
|
||||
|
||||
return (
|
||||
<PageContent
|
||||
title={list.name}
|
||||
|
@ -132,6 +142,14 @@ export default function ListDetail() {
|
|||
onClick={() => setIsUploadOpen(true)}
|
||||
>{t('upload_list')}</Button>}
|
||||
<Button icon={<EditIcon />} onClick={() => setIsEditListOpen(true)}>{t('edit_list')}</Button>
|
||||
<Menu size="regular">
|
||||
<MenuItem onClick={async () => await handleRecountList()}>
|
||||
<RestartIcon />{t('recount')}
|
||||
</MenuItem>
|
||||
<MenuItem onClick={async () => await handleArchiveList()}>
|
||||
<ArchiveIcon />{t('archive')}
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
</>
|
||||
}>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue