Skip to content

Commit

Permalink
Remove "Update all lex entry counts" button (#768)
Browse files Browse the repository at this point in the history
It has served its purpose, and was always intended to be temporary.
  • Loading branch information
rmunn authored May 6, 2024
1 parent b23d37b commit b0d7857
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 27 deletions.
15 changes: 0 additions & 15 deletions backend/LexBoxApi/Controllers/ProjectController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,21 +232,6 @@ public async Task<ActionResult<int>> UpdateLexEntryCount(string code)
return result is null ? NotFound() : result;
}

[HttpPost("updateAllLexEntryCounts")]
[AdminRequired]
public async Task<ActionResult<int>> 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<ActionResult> QueueUpdateProjectMetadataTask(string projectCode)
{
Expand Down
13 changes: 1 addition & 12 deletions frontend/src/routes/(authenticated)/admin/AdminProjects.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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)[]>);
Expand Down Expand Up @@ -69,12 +68,6 @@
notifyWarning($t('delete_project_modal.success', { name: project.name, code: project.code }));
}
}
async function updateAllLexEntryCounts(): Promise<void> {
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!` : ''));
}
</script>

<ConfirmDeleteModal bind:this={deleteProjectModal} i18nScope="delete_project_modal" />
Expand Down Expand Up @@ -144,8 +137,4 @@
<RefineFilterMessage total={filteredProjects.length} showing={shownProjects.length} />
{/if}
{/if}

<DevContent>
<p><span class="text-bold">TEMPORARY:</span> <button class="btn btn-warning" on:click={updateAllLexEntryCounts}> Update all lex entry counts </button>
</DevContent>
</div>

0 comments on commit b0d7857

Please sign in to comment.