From b031462d3817e61ee4d6cff393054ab20e3cffff Mon Sep 17 00:00:00 2001 From: Eric Gauzens Date: Sun, 16 Jun 2024 11:33:25 -0400 Subject: [PATCH 1/2] couple different bug fixes --- components/Header/Header.vue | 2 +- pages/about/index.vue | 21 +++++++++++++++++++-- pages/about/metrics/index.vue | 2 +- pages/about/projects/index.vue | 7 ++++--- pages/data/index.vue | 6 +++++- 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/components/Header/Header.vue b/components/Header/Header.vue index a6a394cc..f149ce36 100644 --- a/components/Header/Header.vue +++ b/components/Header/Header.vue @@ -103,7 +103,7 @@ const links = [ { title: 'data', displayTitle: 'Data & Models', - href: '/data' + href: '/data?type=dataset' }, { title: 'apps', diff --git a/pages/about/index.vue b/pages/about/index.vue index ac1707de..097cae6a 100644 --- a/pages/about/index.vue +++ b/pages/about/index.vue @@ -73,6 +73,21 @@ import marked from '@/mixins/marked' import { getPreviousDate } from '@/utils/common' import { pathOr } from 'ramda' +const months = [ + 'January', + 'Febuary', + 'March', + 'April', + 'May', + 'June', + 'July', + 'August', + 'September', + 'October', + 'November', + 'December' +] + export default { name: 'AboutPage', @@ -118,6 +133,7 @@ export default { const currentYear = new Date().getFullYear() // we use last months date to get the metrics bc the metrics for the current month aren't published until the end of the month const lastMonthsDate = getPreviousDate(currentMonth, currentYear) + let dateUsed = lastMonthsDate return Promise.all([ /** * Page data @@ -143,6 +159,7 @@ export default { }) .catch(() => { const monthBeforeLastDate = getPreviousDate(lastMonthsDate.month, lastMonthsDate.year) + dateUsed = monthBeforeLastDate return $axios .get(config.public.METRICS_URL + `/pennsieve?year=${monthBeforeLastDate.year}&month=${monthBeforeLastDate.month}`) .then(({ data }) => { @@ -191,11 +208,11 @@ export default { metricsItems: [{ title: 'Total Downloads', data: totalDownloads.toString(), - subData: `(${metrics.downloadsLastMonth} last month)` + subData: `(${metrics.downloadsLastMonth} in ${months[dateUsed.month - 1]})` }, { title: 'Dataset Contributors', data: metrics.totalContributors?.toString(), - subData: `(${metrics.newContributors} new in the last month)` + subData: `(${metrics.newContributors} new in ${months[dateUsed.month - 1]})` }] })) }, diff --git a/pages/about/metrics/index.vue b/pages/about/metrics/index.vue index 90dee1c4..7d54e44d 100644 --- a/pages/about/metrics/index.vue +++ b/pages/about/metrics/index.vue @@ -42,7 +42,7 @@ v-else :metrics-data="metricsData" /> -
+
Last metrics update: {{ monthLastUpdate.toLocaleString('default', { month: 'long' }) }} {{ monthLastUpdate.getFullYear() }}
diff --git a/pages/about/projects/index.vue b/pages/about/projects/index.vue index 3eb6fe9e..1beb03d9 100644 --- a/pages/about/projects/index.vue +++ b/pages/about/projects/index.vue @@ -268,10 +268,11 @@ export default { watch: { '$route.query.consortiaType': { - handler: async function () { - if (!this.$route.query.consortiaType) { + handler: function () { + // Added route name check bc clicking on Data & Models header link was causing this to still fire after navigating to the data page + if (!this.$route.query.consortiaType && this.$route.name == 'about-projects') { this.$router.push({ - query: { consortiaType: this.consortiaType['id'] } + query: {consortiaType: this.consortiaType['id'] } }) } else { this.searchData = { diff --git a/pages/data/index.vue b/pages/data/index.vue index 49f79a65..1353c677 100644 --- a/pages/data/index.vue +++ b/pages/data/index.vue @@ -166,7 +166,11 @@ export default { const route = useRoute() if (route.query.type == 'projects') { const focusQuery = route.query.selectedProjectsAnatomicalFocusIds - await navigateTo(`/about/projects?consortiaType=SPARC&selectedProjectsAnatomicalFocusIds=${focusQuery}`) + let newPath = '/about/projects?consortiaType=SPARC' + if (focusQuery) { + newPath += `&selectedProjectsAnatomicalFocusIds=${focusQuery}` + } + return navigateTo(newPath) } const { $algoliaClient } = useNuxtApp() const algoliaSortOptions = [ From 58b155b04c816fed36f00b901bd2c57a704696b3 Mon Sep 17 00:00:00 2001 From: Eric Gauzens Date: Sun, 16 Jun 2024 11:50:16 -0400 Subject: [PATCH 2/2] updated test --- tests/cypress/e2e/homepage.cy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cypress/e2e/homepage.cy.js b/tests/cypress/e2e/homepage.cy.js index 7582259f..e50b2418 100644 --- a/tests/cypress/e2e/homepage.cy.js +++ b/tests/cypress/e2e/homepage.cy.js @@ -12,7 +12,7 @@ describe('Homepage', { testIsolation: false }, function () { it('Navigation Bar', function () { // Check for navigation bar - cy.get('.mobile-navigation > :nth-child(1) > :nth-child(1) > a').should('contain', 'Data & Models').and('have.attr', 'href', '/data') + cy.get('.mobile-navigation > :nth-child(1) > :nth-child(1) > a').should('contain', 'Data & Models').and('have.attr', 'href', '/data?type=dataset') cy.get('.mobile-navigation > :nth-child(1) > :nth-child(2) > a').should('contain', 'SPARC Apps').and('have.attr', 'href', '/apps') cy.get('.mobile-navigation > :nth-child(1) > :nth-child(3) > a').should('contain', 'Tools & Resources').and('have.attr', 'href', '/tools-and-resources') cy.get('.mobile-navigation > :nth-child(1) > :nth-child(4) > a').should('contain', 'News & Events').and('have.attr', 'href', '/news-and-events')