Skip to content

Commit ce72303

Browse files
authored
Merge pull request #296 from Ayushmaanagarwal1211/cursor
Fixed least Likes and Most Likes Filtering
2 parents 5dcfb35 + 764ed28 commit ce72303

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ <h1 class="main-heading">Awesome GitHub Profile READMEs</h1>
121121
<div class="modal-content">
122122
<p class="views">Least Views</p>
123123
<p class="views">Most Views</p>
124-
<p class="likes">Least Likes</p>
125-
<p class="likes">Most Likes</p>
124+
<p class="views">Least Likes</p>
125+
<p class="views">Most Likes</p>
126126
</div>
127127
</div>
128128

scripts/retriveprofile.js

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,8 @@ document.addEventListener('DOMContentLoaded', () => {
402402
contributors=contributors.sort((a,b)=>a.views-b.views)
403403
renderProfiles();
404404
});
405-
}else{
405+
}
406+
else if(e.target.innerHTML=="Most Views"){
406407
fetch("https://raw.githubusercontent.com/recodehive/awesome-github-profiles/main/.all-contributorsrc")
407408
.then((response) => response.json())
408409
.then((data) => {
@@ -421,6 +422,46 @@ document.addEventListener('DOMContentLoaded', () => {
421422
contributors=contributors.sort((a,b)=>b.views-a.views)
422423
renderProfiles();
423424
});
425+
}else if(e.target.innerHTML=="Most Likes"){
426+
console.log('sdsdsdsds')
427+
fetch("https://raw.githubusercontent.com/recodehive/awesome-github-profiles/main/.all-contributorsrc")
428+
.then((response) => response.json())
429+
.then((data) => {
430+
contributors = data.contributors;
431+
contributors.map((data)=>{
432+
const profileRef = firebase.database().ref(`profiles/${data.login}/likes`)
433+
profileRef.on("value", (snapshot) => {
434+
if (snapshot.exists()) {
435+
data['likes']=snapshot.val()
436+
} else {
437+
// Handle new profile
438+
profileRef.set(0);
439+
}
440+
});
441+
})
442+
contributors=contributors.sort((a,b)=>b.likes-a.likes)
443+
renderProfiles();
444+
});
445+
}else{
446+
447+
fetch("https://raw.githubusercontent.com/recodehive/awesome-github-profiles/main/.all-contributorsrc")
448+
.then((response) => response.json())
449+
.then((data) => {
450+
contributors = data.contributors;
451+
contributors.map((data)=>{
452+
const profileRef = firebase.database().ref(`profiles/${data.login}/likes`)
453+
profileRef.on("value", (snapshot) => {
454+
if (snapshot.exists()) {
455+
data['likes']=snapshot.val()
456+
} else {
457+
// Handle new profile
458+
profileRef.set(0);
459+
}
460+
});
461+
})
462+
contributors=contributors.sort((a,b)=>a.likes-b.likes)
463+
renderProfiles();
464+
});
424465
}
425466
})
426467
})

0 commit comments

Comments
 (0)