-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
166 additions
and
23,604 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
/node_modules | ||
/certs | ||
/src/project-reading | ||
/src/rpgf5-data-import | ||
|
||
# Envs | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,53 @@ | ||
import axios from 'axios'; | ||
import { AgoraApiResponse, Project } from './types'; | ||
import * as fs from 'fs'; | ||
|
||
async function getAllProjects(): Promise<Project[]> { | ||
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<AgoraApiResponse>(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; | ||
} | ||
} | ||
|
||
return allProjects; | ||
} | ||
import { projects } from './all-projects'; | ||
import { projects as gProjects } from './gsheet'; | ||
|
||
// async function getAllProjects(): Promise<Project[]> { | ||
// 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<AgoraApiResponse>(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; | ||
// } | ||
// } | ||
|
||
// return allProjects; | ||
// } | ||
|
||
export const main = async () => { | ||
const categories: Record<string, number> = {}; | ||
|
||
const projects = await getAllProjects(); | ||
|
||
console.log('projects length', projects.length); | ||
|
||
const jsonString = JSON.stringify( | ||
projects.filter((item) => item.applicationCategory === 'OP_STACK_TOOLING'), | ||
null, | ||
2, | ||
console.log( | ||
projects.filter( | ||
(item) => | ||
!gProjects.find( | ||
(el) => | ||
el['isSelected'] === 'Approved' && | ||
el.name.trim() === item.name.trim(), | ||
), | ||
), | ||
); | ||
|
||
fs.writeFile('ost.json', jsonString, (err) => { | ||
if (err) { | ||
console.error('Error writing file', err); | ||
} else { | ||
console.log('JSON file saved successfully'); | ||
} | ||
}); | ||
}; | ||
|
||
void main(); |
Oops, something went wrong.