Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Stats.js): display correct monthly measurements after changing language #886

Merged
merged 2 commits into from
Jan 6, 2024

Conversation

Lanius-collaris
Copy link
Contributor

@Lanius-collaris Lanius-collaris commented Nov 13, 2023

Fixes #873

Copy link

vercel bot commented Nov 13, 2023

@Lanius-collaris is attempting to deploy a commit to the OONI Team on Vercel.

A member of the Team first needs to authorize it.

@Lanius-collaris Lanius-collaris changed the title Stats.js: display correct monthly measurements after changing language fix(Stats.js): display correct monthly measurements after changing language Nov 13, 2023
@Lanius-collaris
Copy link
Contributor Author

ping @majakomel

@Lanius-collaris
Copy link
Contributor Author

@sloncocs 🥲Could you review #886 and #884 ?

@sloncocs
Copy link

sloncocs commented Jan 5, 2024

@sloncocs 🥲Could you review #886 and #884 ?

unfortunately, I cannot as I am not a developer 😢 but I think the right person to tag here is @jbonisteel

Copy link

vercel bot commented Jan 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
explorer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 6, 2024 7:07pm

@Lanius-collaris
Copy link
Contributor Author

🥲This patch doesn't work for master. Checking...

@Lanius-collaris
Copy link
Contributor Author

Lanius-collaris commented Jan 6, 2024

🥲This patch doesn't work for master. Checking...

dt.getUTCFullYear() === today.getUTCFullYear()
🤦 In January, you can't get last month data...

const getLastMonthData = (collection) => {
const cc = collection.filter(d => {
const dt = new Date(Date.parse(d.date))
const today = new Date()
return (dt.getUTCFullYear() === today.getUTCFullYear()) && (today.getUTCMonth() - dt.getUTCMonth() === 1)
})
return cc.length === 0 ? 0 : cc[0]?.value ?? 0
}

Because there is no data in January 2024, after .slice(0,-1), all fields of lastMonth are set to 0.

Also add a workaround for missing data in January 2024
Copy link
Contributor

@majakomel majakomel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for fixing the bugs!

@majakomel majakomel merged commit ad39cbc into ooni:master Jan 6, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OONI Explorer starting page shows 0 monthly measurements in the localized versions of the page
3 participants