Skip to content

Commit

Permalink
Merge pull request #780 from autonomys/revert-779-temp_build_novermbe…
Browse files Browse the repository at this point in the history
…r_2024_leaderboard

Revert "Hardcode the dates for November 2024 to build the leaderboard"
  • Loading branch information
EmilFattakhov authored Dec 4, 2024
2 parents c8bb492 + 03015ba commit 82714cc
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions .github/scripts/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,14 @@ function generateKey(name) {
return crypto.createHash('sha256').update(normalized).digest('hex');
}

// Change start and end dates
const startDate = "2024-11-01T00:00:00+00:00";
const endDate = "2024-11-30T23:59:59+00:00";
function formatDateToBeginningOfMonth(date) {
const year = date.getFullYear();
const month = date.getMonth() + 1; // getMonth() is zero-indexed

return `${year}-${month.toString().padStart(2, '0')}-01T00:00:00+00:00`;
}

const formattedDate = formatDateToBeginningOfMonth(date);

async function getProjectMembers() {
try {
Expand All @@ -85,12 +90,14 @@ async function getProjectMembers() {
}
}



async function generateMonthlyReport() {
try {
const response = await makeRequest('post', `${CONFIG.CROWDIN_API_ENDPOINT}/projects/${CONFIG.CROWDIN_PROJECT_ID}/reports`, {
data: {
name: "top-members",
schema: { unit: "words", format: "csv", dateFrom: startDate, dateTo: endDate } // Updated date range
schema: { unit: "words", format: "csv", dateFrom: formattedDate }
},
headers: { 'Authorization': `Bearer ${CROWDIN_PERSONAL_TOKEN}`, 'Content-Type': 'application/json' }
});
Expand Down Expand Up @@ -217,4 +224,5 @@ async function saveDataToJson(data, filePath) {
} catch (error) {
console.error('Error in main function:', error);
}
})();
})();

0 comments on commit 82714cc

Please sign in to comment.