From b0d78578643abcd5405c52c4def764bccf6d2bcf Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Mon, 6 May 2024 13:18:16 +0700 Subject: [PATCH] Remove "Update all lex entry counts" button (#768) It has served its purpose, and was always intended to be temporary. --- .../LexBoxApi/Controllers/ProjectController.cs | 15 --------------- .../(authenticated)/admin/AdminProjects.svelte | 13 +------------ 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/backend/LexBoxApi/Controllers/ProjectController.cs b/backend/LexBoxApi/Controllers/ProjectController.cs index 29da77283..deedcfb5b 100644 --- a/backend/LexBoxApi/Controllers/ProjectController.cs +++ b/backend/LexBoxApi/Controllers/ProjectController.cs @@ -232,21 +232,6 @@ public async Task> UpdateLexEntryCount(string code) return result is null ? NotFound() : result; } - [HttpPost("updateAllLexEntryCounts")] - [AdminRequired] - public async Task> UpdateAllLexEntryCounts(bool onlyUnknown = true, int limit = 100, int delayMs = 10) - { - var projects = lexBoxDbContext.Projects.Where(p => (p.Type == ProjectType.FLEx || p.Type == ProjectType.WeSay) && (!onlyUnknown || p.FlexProjectMetadata == null)).Take(limit).ToArray(); - var completed = 0; - foreach (var project in projects) - { - await projectService.UpdateLexEntryCount(project.Code); - completed++; - if (delayMs > 0) await Task.Delay(delayMs); - } - return Ok(completed); - } - [HttpPost("queueUpdateProjectMetadataTask")] public async Task QueueUpdateProjectMetadataTask(string projectCode) { diff --git a/frontend/src/routes/(authenticated)/admin/AdminProjects.svelte b/frontend/src/routes/(authenticated)/admin/AdminProjects.svelte index 8bf3718be..8a99bc991 100644 --- a/frontend/src/routes/(authenticated)/admin/AdminProjects.svelte +++ b/frontend/src/routes/(authenticated)/admin/AdminProjects.svelte @@ -22,7 +22,6 @@ import {type QueryParams, toSearchParams} from '$lib/util/query-params'; import {derived} from 'svelte/store'; import type {AdminSearchParams, DraftProject} from './+page'; - import DevContent from '$lib/layout/DevContent.svelte'; import AdminTabs from './AdminTabs.svelte'; import type {CreateProjectInput} from '$lib/gql/types'; @@ -33,7 +32,7 @@ $: filters = queryParamValues; $: filterDefaults = queryParams.defaultQueryParamValues; - const { notifyWarning, notifySuccess } = useNotifications(); + const { notifyWarning } = useNotifications(); const serverSideProjectFilterKeys = (['showDeletedProjects'] as const satisfies Readonly<(keyof ProjectFilters)[]>); @@ -69,12 +68,6 @@ notifyWarning($t('delete_project_modal.success', { name: project.name, code: project.code })); } } - - async function updateAllLexEntryCounts(): Promise { - const result = await fetch(`/api/project/updateAllLexEntryCounts?onlyUnknown=true`, {method: 'POST'}); - const count = await result.text(); - notifySuccess(`${count} projects updated` + (Number(count) == 0 ? `. You're all done!` : '')); - } @@ -144,8 +137,4 @@ {/if} {/if} - - -

TEMPORARY: -