This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

feat: add hackatime v2 as a working option

+15 -15
+1 -1
src/features/takes/handlers/upload.ts
··· 83 83 JSON.parse(userInDB.hackatimeKeys), 84 84 new Date(userInDB.lastTakeUploadDate), 85 85 new Date(), 86 - ).then((res) => res.total_categories_sum || 0); 86 + ).then((res) => res.total_projects_sum || 0); 87 87 88 88 if (timeSpent < 360) { 89 89 await slackClient.chat.postMessage({
+14 -14
src/libs/hackatime.ts
··· 9 9 }, 10 10 v2: { 11 11 id: "v2", 12 - name: "Hackatime V2 (broken don't use)", 13 - apiUrl: "https://waka.hackclub.com/api", 12 + name: "Hackatime V2", 13 + apiUrl: "https://hackatime.hackclub.com/api", 14 14 }, 15 15 } as const; 16 16 ··· 84 84 end: string; 85 85 timezone: string; 86 86 }; 87 - total_categories_sum?: number; 88 - total_categories_human_readable?: string; 87 + total_projects_sum?: number; 88 + total_projects_human_readable?: string; 89 89 projectsKeys?: string[]; 90 90 } 91 91 ··· 132 132 languages: [], 133 133 editors: [], 134 134 operating_systems: [], 135 - total_categories_sum: 0, 136 - total_categories_human_readable: "0h 0m 0s", 135 + total_projects_sum: 0, 136 + total_projects_human_readable: "0h 0m 0s", 137 137 projectsKeys: [], 138 138 }; 139 139 } ··· 145 145 const data = await response.json(); 146 146 147 147 // Add derived properties similar to the shell command 148 - const totalCategoriesSum = 149 - data.categories?.reduce( 150 - (sum: number, category: { total: number }) => sum + category.total, 148 + const totalProjectsSum = 149 + data.projects?.reduce( 150 + (sum: number, project: { total: number }) => sum + project.total, 151 151 0, 152 152 ) || 0; 153 - const hours = Math.floor(totalCategoriesSum / 3600); 154 - const minutes = Math.floor((totalCategoriesSum % 3600) / 60); 155 - const seconds = totalCategoriesSum % 60; 153 + const hours = Math.floor(totalProjectsSum / 3600); 154 + const minutes = Math.floor((totalProjectsSum % 3600) / 60); 155 + const seconds = totalProjectsSum % 60; 156 156 157 157 // Get all project keys from the data 158 158 const allProjectsKeys = ··· 170 170 171 171 return { 172 172 ...data, 173 - total_categories_sum: totalCategoriesSum, 174 - total_categories_human_readable: `${hours}h ${minutes}m ${seconds}s`, 173 + total_projects_sum: totalProjectsSum, 174 + total_projects_human_readable: `${hours}h ${minutes}m ${seconds}s`, 175 175 projectsKeys: projectsKeys, 176 176 }; 177 177 }