-
Notifications
You must be signed in to change notification settings - Fork 4
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
Fixed incorrect badge count if there's no gold badge #3
base: main
Are you sure you want to change the base?
Conversation
I wanted to use this widget in my profile, but the badge count was incorrectly displaying, it was because i don't have gold badge, but i have silver and bronze badges, so the previous code was setting bronze count into gold count.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your time @kashifo, just some small reviews, rest looks good, please upload photo with this change for missing badges and for the user who has all the badges
const $ = cheerio.load(html); | ||
|
||
const detailsDiv = $("div.d-flex.flex__fl-equal.fw-wrap.gs24").first(); | ||
const badgeDivs = detailsDiv.find("div.fs-title"); 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this 1? compilation isn't failing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's a typo, I had it fixed in the immediate next commit
const bronzeBadges = detailsDiv.find("div.badge-bronze").text().trim(); | ||
|
||
// If class names are not found or not reliable, use text content as a fallback | ||
if (!goldBadges || !silverBadges || !bronzeBadges) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If any one is not available why are we processing for all ? any reason.
Let's say goldbadges is not there silverBadges and bronzeBadges exists.
Then we are recalculating for silverbadges and bronzebadges even. can we try to optimize this , or any particular reason this is written this way?
Hey @krishnaacharyaa , Here's an idea which works properly, Shall I integrate StackOverflow's API? I was wondering why you're scraping instead of using their API, then I found out myself that you want to display your reach which is great, which is not available in API. So, shall we use the API for all other values, use scraping only for getting the reach value? |
@krishnaacharyaa Have been waiting for your reply on this? |
I wanted to use this widget in my profile, but the badge count was incorrectly displaying, it was because i don't have gold badge, but i have silver and bronze badges, so the previous code was setting bronze count into gold count.