Skip to content

Commit

Permalink
implemented requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
yash-succesship committed Jan 21, 2025
1 parent e04b709 commit 445abc6
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions frontend/src/utils/helpers/githubHeatmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export const drawContributions = (canvas, { data, username, theme }) => {
data,
username,
themeName: theme,
skipHeader: true,
skipAxisLabel: true,
})
}

Expand All @@ -18,30 +20,26 @@ const getColor = (count) => {
}

const getIntensity = (count) => {
if (count === 0) {
return '0'
} else if (count == 1 || count == 2) {
return '1'
} else if (count >= 3 && count <= 5) {
return '2'
} else if (count >= 6 && count <= 10) {
return '3'
} else {
return '4'
}
if (count === 0) return '0'
if (count <= 2) return '1'
if (count <= 5) return '2'
if (count <= 10) return '3'
return '4'
}

export const fetchHeatmapData = async (username) => {
try {
const data = await fetch(`https://github-contributions-api.jogruber.de/v4/${username}`)
const data2 = await data.json()
data2.contributions = data2.contributions.filter((item) => item.date.split('-')[0] === '2024')
const response = await fetch(`https://github-contributions-api.jogruber.de/v4/${username}`)
const heatmapData = await response.json()
heatmapData.contributions = heatmapData.contributions.filter(
(item) => item.date.split('-')[0] === '2024'
)

const transformedContributions = []
const allDates = data2.contributions.map((contribution) => contribution.date)
const allDates = heatmapData.contributions.map((contribution) => contribution.date)

for (let date of allDates) {
const contribution = data2.contributions.find((c) => c.date === date)
const contribution = heatmapData.contributions.find((c) => c.date === date)
if (contribution) {
transformedContributions.push({
date: contribution.date,
Expand All @@ -62,10 +60,10 @@ export const fetchHeatmapData = async (username) => {
years: [
{
year: '2024',
total: data2.total['2024'],
total: heatmapData.total['2024'],
range: {
start: '2024-01-07',
end: '2024-12-28',
start: '2024-01-01',
end: '2024-12-31',
},
},
],
Expand Down

0 comments on commit 445abc6

Please sign in to comment.