Skip to content

Commit

Permalink
Merge pull request #132 from nih-sparc/Miscellaneous-fixes
Browse files Browse the repository at this point in the history
couple different bug fixes
  • Loading branch information
egauzens authored Jun 16, 2024
2 parents 7c74c98 + 58b155b commit bef2f26
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion components/Header/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const links = [
{
title: 'data',
displayTitle: 'Data & Models',
href: '/data'
href: '/data?type=dataset'
},
{
title: 'apps',
Expand Down
21 changes: 19 additions & 2 deletions pages/about/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand All @@ -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 }) => {
Expand Down Expand Up @@ -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]})`
}]
}))
},
Expand Down
2 changes: 1 addition & 1 deletion pages/about/metrics/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
v-else
:metrics-data="metricsData"
/>
<div class="row my-32">
<div class="body1 ml-16">
Last metrics update: {{ monthLastUpdate.toLocaleString('default', { month: 'long' }) }} {{ monthLastUpdate.getFullYear() }}
</div>
</div>
Expand Down
7 changes: 4 additions & 3 deletions pages/about/projects/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
6 changes: 5 additions & 1 deletion pages/data/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/e2e/homepage.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit bef2f26

Please sign in to comment.