From 75380b98e0ee56e0008ee927aee699c2e80f24fc Mon Sep 17 00:00:00 2001 From: Eric Gauzens Date: Thu, 17 Oct 2024 15:10:49 -0400 Subject: [PATCH 1/2] updated profile page published datasets section to pull from Algolia --- pages/user/profile/index.vue | 54 +++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/pages/user/profile/index.vue b/pages/user/profile/index.vue index 99bfeb1f..08e3f569 100644 --- a/pages/user/profile/index.vue +++ b/pages/user/profile/index.vue @@ -393,7 +393,8 @@ export default { handler: async function (newValue) { if (newValue && newValue !== '') { await this.fetchOrganizations() - this.fetchUserDatasets() + this.fetchPublishedDatasets(newValue) + this.fetchInProgressDatasets() this.fetchDatasetSubmissions() this.fetchQuestions() } @@ -402,7 +403,36 @@ export default { }, }, methods: { - async fetchUserDatasets() { + async fetchPublishedDatasets(orcid) { + const filter = `contributors.curie:\"ORCID:${orcid}\"` + try { + const { hits } = await this.$algoliaClient.initIndex(this.$config.public.ALGOLIA_INDEX).search('', { + filters: filter, + hitsPerPage: 999 + }) + let items = [] + for (const hit of hits) { + const datasetName = pathOr('', ['item', 'name'], hit) + const datasetId = propOr('', 'objectID', hit) + const pennsieveIdentifier = pathOr('', ['item', 'identifier'], hit) + let numCitations = await this.getCitationsCount(pennsieveIdentifier) + const numDownloads = this.getDownloadsCount(datasetId); + items.push({ + 'name': datasetName, + 'intId': datasetId, + 'banner': pathOr('', ['pennsieve', 'banner', 'uri'], hit), + 'numDownloads': numDownloads, + 'numCitations': numCitations + }) + } + this.datasets = items + } catch (error) { + this.datasets = [] + } finally { + this.datasetsLoading = false + } + }, + async fetchInProgressDatasets() { let orgIntIds = [] this.organizations.forEach(org => { orgIntIds.push(org.intId) @@ -413,7 +443,6 @@ export default { await this.$axios.put(`${this.$config.public.LOGIN_API_URL}/session/switch-organization?organization_id=${id}&api_key=${this.userToken}`) let { data } = await this.$axios.get(`${this.$config.public.LOGIN_API_URL}/datasets/paginated?onlyMyDatasets=true&api_key=${this.userToken}`) - const publishedDatasets = data.datasets.filter(dataset => dataset.publication.status == 'completed') const inProgressDatasets = data.datasets.filter(dataset => dataset.publication.status != 'completed') for (let dataset of inProgressDatasets) { @@ -424,29 +453,10 @@ export default { banner: data.banner }) } - - for (let dataset of publishedDatasets) { - const intId = pathOr('', ['content', 'intId'], dataset) - const datasetName = pathOr('', ['content', 'name'], dataset) - const pennsieveIdentifier = pathOr('', ['content', 'id'], dataset) - - let { data } = await this.$axios.get(`${this.$config.public.LOGIN_API_URL}/datasets/${pennsieveIdentifier}/banner?api_key=${this.userToken}`) - let numCitations = await this.getCitationsCount(pennsieveIdentifier) - const numDownloads = this.getDownloadsCount(intId) - - this.datasets.push({ - 'name': datasetName, - 'intId': intId, - 'banner': data.banner, - 'numDownloads': numDownloads, - 'numCitations': numCitations - }) - } } catch (e) { } } this.inProgressDatasetsLoading = false - this.datasetsLoading = false }, async fetchDatasetSubmissions() { const headers = { 'Authorization': `Bearer ${this.userToken}` } From f7637270707ebf2ec795bb38cea8dcbdcb7ed081 Mon Sep 17 00:00:00 2001 From: Eric Gauzens Date: Thu, 17 Oct 2024 15:16:39 -0400 Subject: [PATCH 2/2] updated tooltip to mention expected delay --- pages/user/profile/index.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pages/user/profile/index.vue b/pages/user/profile/index.vue index 08e3f569..84ebbf58 100644 --- a/pages/user/profile/index.vue +++ b/pages/user/profile/index.vue @@ -144,9 +144,9 @@
My published Datasets relates to all Datasets, Computational and Anatomical models where you have - been - associated to the dataset using your ORCID number. If there are datasets that you feel should be - linked to you please contact curation@sparc.science + been associated to the dataset using your ORCID number. Please note that there may be a delay in recently + published datasets being immediately available on the portal. + If there are datasets that you feel should be linked to you please contact curation@sparc.science