Skip to content

Commit

Permalink
Update ballot projects
Browse files Browse the repository at this point in the history
  • Loading branch information
mmahdigh committed Sep 27, 2024
1 parent 7e327e5 commit 2e78e36
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 23,604 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/node_modules
/certs
/src/project-reading
/src/rpgf5-data-import

# Envs

Expand Down
19 changes: 12 additions & 7 deletions src/flow/flow.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,23 @@ import { PairsResult } from './dto/pairsResult';
import { sortProjectId } from 'src/utils';
import { RemoveLastVoteDto, SetCoIDto } from './dto/bodies';
import { AgoraBallotPost } from 'src/rpgf5-data-import/submit';
import { projects as osradProjects } from 'src/rpgf5-data-import/osrad';
import { projects as eccProjects } from 'src/rpgf5-data-import/ecc';
import { projects as ostProjects } from 'src/rpgf5-data-import/ost';
import { projects } from 'src/rpgf5-data-import/all-projects';

export const getAllProjects = (category: number) => {
switch (category) {
case 1:
return eccProjects;
case 2:
return ostProjects;
return projects.filter(
(el) => el['applicationCategory'] === 'ETHEREUM_CORE_CONTRIBUTIONS',
);
case 3:
return osradProjects;
return projects.filter(
(el) => el['applicationCategory'] === 'OP_STACK_TOOLING',
);
case 1:
return projects.filter(
(el) =>
el['applicationCategory'] === 'OP_STACK_RESEARCH_AND_DEVELOPMENT',
);
default:
throw new Error(`Invalid category id ${category}`);
}
Expand Down
5,825 changes: 0 additions & 5,825 deletions src/rpgf5-data-import/ecc.ts

This file was deleted.

15 changes: 8 additions & 7 deletions src/rpgf5-data-import/icats-insert.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PrismaClient } from '@prisma/client';
import { projects } from './icats';
import { projects } from './gsheet';

const implicitCatDist = async (prisma: PrismaClient) => {
const projects = await prisma.project.findMany({
Expand Down Expand Up @@ -41,16 +41,17 @@ export const main = async () => {

console.log('Connected!');

// const nullPs = await prisma.project.findMany({
// select: { name: true },
// where: { type: 'project', implicitCategory: null },
// });
const nullPs = await prisma.project.findMany({
select: { name: true },
where: { type: 'project', implicitCategory: null },
});

// console.log(nullPs);
console.log(nullPs);

// for (let i = 0; i < projects.length; i++) {
// console.log('Project', i);
// const project = projects[i];
// if (project.isSelected !== 'Approved') continue;
// console.log('Project', i);
// const exists = await prisma.project.findFirst({
// where: { name: project.name, implicitCategory: null },
// });
Expand Down
6,131 changes: 0 additions & 6,131 deletions src/rpgf5-data-import/icats.ts

This file was deleted.

95 changes: 44 additions & 51 deletions src/rpgf5-data-import/index copy.ts
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();
Loading

0 comments on commit 2e78e36

Please sign in to comment.