diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2657f753..6956e0056 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -137,7 +137,7 @@ jobs: with: repository: opendatateam/udata path: ${{ env.UDATA_WORKING_DIR }} - ref: main + ref: switch_harvests_to_new_api_fields - name: Set up uv uses: astral-sh/setup-uv@v6 diff --git a/components/Harvesters/AdminHarvestersPage.vue b/components/Harvesters/AdminHarvestersPage.vue index a0d2a00d7..8bc18da38 100644 --- a/components/Harvesters/AdminHarvestersPage.vue +++ b/components/Harvesters/AdminHarvestersPage.vue @@ -192,7 +192,7 @@ import HarvesterBadge from './HarvesterBadge.vue' import type { PaginatedArray } from '~/types/types' import AdminTable from '~/components/AdminTable/Table/AdminTable.vue' import AdminTableTh from '~/components/AdminTable/Table/AdminTableTh.vue' -import type { HarvesterJob, HarvesterSource } from '~/types/harvesters' +import type { HarvesterSource } from '~/types/harvesters' import { getHarvesterAdminUrl } from '~/utils/harvesters' const props = defineProps<{ @@ -201,7 +201,6 @@ const props = defineProps<{ const { t } = useTranslation() const { formatDate } = useFormatDate() const config = useRuntimeConfig() -const { $api } = useNuxtApp() const page = ref(1) const pageSize = ref(20) @@ -225,38 +224,11 @@ const url = computed(() => { const { data: pageData, status } = await useAPI>(url, { lazy: true }) -const jobs = ref>({}) -const jobsPromises = ref>>({}) - -watchEffect(async () => { - if (!pageData.value) return - - for (const source of pageData.value.data) { - if (!source.last_job) continue - if (source.last_job.id in jobsPromises.value) continue - - jobsPromises.value[source.last_job.id] = $api(`/api/1/harvest/job/${source.last_job.id}/`) - .then((job) => { - if (source.last_job) { - jobs.value[source.last_job.id] = job // Working because there is no conflicts between IDs from different types - } - }) - } - - await Promise.all(Object.values(jobsPromises.value)) -}) - function getHarvesterDataservices(harvester: HarvesterSource) { - if (!harvester.last_job || !jobs.value[harvester.last_job.id]) { - return 0 - } - return jobs.value[harvester.last_job.id].items.filter(item => item.dataservice).length + return harvester.last_job?.items.by_type.dataservice ?? 0 } function getHarvesterDatasets(harvester: HarvesterSource) { - if (!harvester.last_job || !jobs.value[harvester.last_job.id]) { - return 0 - } - return jobs.value[harvester.last_job.id].items.filter(item => item.dataset).length + return harvester.last_job?.items.by_type.dataset ?? 0 } diff --git a/components/Harvesters/JobBadge.vue b/components/Harvesters/JobBadge.vue index 5e094183f..569bb8c0f 100644 --- a/components/Harvesters/JobBadge.vue +++ b/components/Harvesters/JobBadge.vue @@ -9,11 +9,11 @@