From bda96720a22d0b3fe6b03110be6a3ad26e2d6ded Mon Sep 17 00:00:00 2001 From: Mahdi Date: Fri, 27 Sep 2024 18:40:51 +0330 Subject: [PATCH] comment --- src/rpgf5-data-import/submit.ts | 114 ++++++++++++++++---------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/src/rpgf5-data-import/submit.ts b/src/rpgf5-data-import/submit.ts index 85dc37f..fe734ed 100644 --- a/src/rpgf5-data-import/submit.ts +++ b/src/rpgf5-data-import/submit.ts @@ -1,37 +1,37 @@ -import { projects } from './osrad'; -import * as fs from 'fs'; -// async function getAllProjects(): Promise { -// const baseUrl = -// 'https://vote.optimism.io/api/v1/retrofunding/rounds/5/projects'; -// const limit = 100; // Maximum allowed limit -// let offset = 0; -// let allProjects: Project[] = []; -// let hasNext = true; +// import { projects } from './osrad'; +// import * as fs from 'fs'; +// // async function getAllProjects(): Promise { +// // const baseUrl = +// // 'https://vote.optimism.io/api/v1/retrofunding/rounds/5/projects'; +// // const limit = 100; // Maximum allowed limit +// // let offset = 0; +// // let allProjects: Project[] = []; +// // let hasNext = true; -// while (hasNext) { -// try { -// const response = await axios.get(baseUrl, { -// params: { -// offset, -// limit, -// }, -// headers: { -// Authorization: 'Bearer 80963194-c250-4a37-921a-302bf50dee34', -// }, -// timeout: 30 * 1000, -// }); +// // while (hasNext) { +// // try { +// // const response = await axios.get(baseUrl, { +// // params: { +// // offset, +// // limit, +// // }, +// // headers: { +// // Authorization: 'Bearer 80963194-c250-4a37-921a-302bf50dee34', +// // }, +// // timeout: 30 * 1000, +// // }); -// allProjects = allProjects.concat(response.data.data); -// hasNext = response.data.meta.has_next; -// offset = response.data.meta.next_offset; -// } catch (error) { -// console.error('Error fetching projects:', error); -// break; -// } -// } +// // allProjects = allProjects.concat(response.data.data); +// // hasNext = response.data.meta.has_next; +// // offset = response.data.meta.next_offset; +// // } catch (error) { +// // console.error('Error fetching projects:', error); +// // break; +// // } +// // } -// return allProjects; -// } +// // return allProjects; +// // } export type AgoraBallotPost = { projects: { @@ -41,37 +41,37 @@ export type AgoraBallotPost = { }[]; }; -const createFakeDistribution = (total: number) => { - const distribution = []; +// const createFakeDistribution = (total: number) => { +// const distribution = []; - for (let i = 0; i < total; i++) { - distribution.push(Math.random()); - } +// for (let i = 0; i < total; i++) { +// distribution.push(Math.random()); +// } - const initialSum = distribution.reduce((a, b) => a + b, 0); +// const initialSum = distribution.reduce((a, b) => a + b, 0); - const coefficient = 100 / initialSum; +// const coefficient = 100 / initialSum; - return distribution.map((el) => Math.round(el * coefficient * 1000) / 1000); -}; +// return distribution.map((el) => Math.round(el * coefficient * 1000) / 1000); +// }; -export const main = async () => { - const dist = createFakeDistribution(projects.length); - const ballot = projects.map((item, index) => ({ - project_id: item.id, - allocation: `${dist[index]}`, - impact: Math.round(Math.random() * 4) + 1, - })); +// export const main = async () => { +// const dist = createFakeDistribution(projects.length); +// const ballot = projects.map((item, index) => ({ +// project_id: item.id, +// allocation: `${dist[index]}`, +// impact: Math.round(Math.random() * 4) + 1, +// })); - const jsonString = JSON.stringify(ballot, null, 2); +// const jsonString = JSON.stringify(ballot, null, 2); - fs.writeFile('ballot.json', jsonString, (err) => { - if (err) { - console.error('Error writing file', err); - } else { - console.log('JSON file saved successfully'); - } - }); -}; +// fs.writeFile('ballot.json', jsonString, (err) => { +// if (err) { +// console.error('Error writing file', err); +// } else { +// console.log('JSON file saved successfully'); +// } +// }); +// }; -void main(); +// void main();