Skip to content

Commit

Permalink
hand-selected generation
Browse files Browse the repository at this point in the history
  • Loading branch information
akorchyn committed Sep 27, 2024
1 parent 6d219f6 commit 794e331
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 53 deletions.
94 changes: 50 additions & 44 deletions issue_creator/hand_selected.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,52 @@
[
"https://github.com/wevm/isows",
"https://github.com/coinbase/coinbase-wallet-sdk",
"https://github.com/RienNeVaPlus/human-id",
"https://github.com/toml-rs/toml",
"https://github.com/moment/moment",
"https://github.com/time-rs/time",
"https://github.com/ethers-io/ethers.js",
"https://github.com/sinonjs/fake-timers",
"https://github.com/typescript-eslint/typescript-eslint",
"https://github.com/sfackler/rust-openssl",
"https://github.com/faisalman/ua-parser-js",
"https://github.com/paupino/rust-decimal",
"https://github.com/hwchen/keyring-rs",
"https://github.com/IonicaBizau/anser",
"https://github.com/soldair/node-qrcode",
"https://github.com/protobufjs/protobuf.js",
"https://github.com/JoshuaKGoldberg/ts-api-utils",
"https://github.com/StableLib/stablelib",
"https://github.com/JakeChampion/fetch",
"https://github.com/true-myth/true-myth",
"https://github.com/css-modules/generic-names",
"https://github.com/GoogleChrome/workbox",
"https://github.com/piscinajs/piscina",
"https://github.com/rustwasm/wasm-bindgen",
"https://github.com/prettier/eslint-plugin-prettier",
"https://github.com/react-component/image",
"https://github.com/ai/nanoid",
"https://github.com/radix-ui/primitives",
"https://github.com/babel/babel",
"https://github.com/react-native-webview/react-native-webview",
"https://github.com/bripkens/connect-history-api-fallback",
"https://github.com/paperclip-rs/paperclip",
"https://github.com/hyperium/h2",
"https://github.com/quinn-rs/quinn",
"https://github.com/kozakdenys/qr-code-styling",
"https://github.com/jestjs/jest",
"https://github.com/immutable-js/immutable-js",
"https://github.com/jonasbb/serde_with",
"https://github.com/remarkjs/react-markdown",
"https://github.com/rust-pretty-assertions/rust-pretty-assertions",
"https://github.com/CensoredUsername/dynasm-rs",
"https://github.com/theKashey/react-remove-scroll-bar",
"https://github.com/redis-rs/redis-rs",
"https://github.com/paulmillr/readdirp"
"https://github.com/MetaMask/eth-json-rpc-filters",
"https://github.com/kornelski/rust-security-framework",
"https://github.com/pmmmwh/react-refresh-webpack-plugin",
"https://github.com/wasmerio/wasmer",
"https://github.com/typicode/husky",
"https://github.com/RazrFalcon/memmap2-rs",
"https://github.com/nrwl/nx",
"https://github.com/smithy-lang/smithy-typescript",
"https://github.com/micromatch/braces",
"https://github.com/hsivonen/encoding_rs",
"https://github.com/hapijs/joi",
"https://github.com/indexmap-rs/indexmap",
"https://github.com/jsdom/jsdom",
"https://github.com/bnjmnt4n/regjsgen",
"https://github.com/testcontainers/testcontainers-rs",
"https://github.com/blakeembrey/change-case",
"https://github.com/davidjbradshaw/iframe-resizer",
"https://github.com/servo/rust-url",
"https://github.com/GleapSDK/JavaScript-SDK",
"https://github.com/mstange/samply",
"https://github.com/colinhacks/zod",
"https://github.com/jam1garner/owo-colors",
"https://github.com/sindresorhus/cli-spinners",
"https://github.com/lddubeau/xmlchars",
"https://github.com/unicode-org/icu4x",
"https://github.com/isaacs/node-graceful-fs",
"https://github.com/sdroege/byte-slice-cast",
"https://github.com/lerna/lerna",
"https://github.com/preactjs/preact",
"https://github.com/paritytech/parity-scale-codec",
"https://github.com/mikaelmello/inquire",
"https://github.com/sveltejs/svelte",
"https://github.com/http-party/node-http-proxy",
"https://github.com/react-bootstrap/prop-types-extra",
"https://github.com/eslint-community/regexpp",
"https://github.com/tj/commander.js",
"https://github.com/10XGenomics/lz4-rs",
"https://github.com/adobe/react-spectrum",
"https://github.com/jspm/generator",
"https://github.com/JedWatson/classnames",
"https://github.com/lydell/eslint-plugin-simple-import-sort",
"https://github.com/sunfishcode/is-terminal",
"https://github.com/smol-rs/async-io",
"https://github.com/jaredwray/cacheable",
"https://github.com/react-syntax-highlighter/react-syntax-highlighter",
"https://github.com/handlebars-lang/handlebars.js",
"https://github.com/salesforce/tough-cookie",
"https://github.com/dai-shi/proxy-compare",
"https://github.com/tschaub/gh-pages",
"https://github.com/react-hook-form/react-hook-form"
]
54 changes: 45 additions & 9 deletions issue_creator/src/issue_creator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import cliProgress from 'cli-progress';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import _ from 'lodash';
import path from 'path';

// Parse command-line arguments
const argv = yargs(hideBin(process.argv))
Expand Down Expand Up @@ -35,6 +36,17 @@ const argv = yargs(hideBin(process.argv))
description: "Limit the number of issues to create",
type: "number",
})
.option("generate", {
alias: "g",
description: "Generate hand-selected repositories list",
type: "boolean",
})
.option("output", {
alias: "o",
description: "Output file for hand-selected repositories",
type: "string",
default: "hand_selected.json",
})
.help()
.alias("help", "h")
.parse();
Expand Down Expand Up @@ -120,6 +132,30 @@ async function createIssueWithRetry(owner, repo, issueContent, retries = 0) {
}
}

async function generateHandSelectedList(repositories, progress, limit) {
const processedOrgs = new Set(
Object.keys(progress)
.filter(repo => progress[repo] && !progress[repo].error)
.map(getOrgFromRepo)
);

const unprocessedRepos = repositories.filter(repo => {
const org = getOrgFromRepo(repo);
return !processedOrgs.has(org) && (!progress[repo] || progress[repo].error);
});

const reposByOrg = _.groupBy(unprocessedRepos, getOrgFromRepo);

// Select one random repo from each unprocessed org
const selectedRepos = Object.values(reposByOrg)
.map(orgRepos => _.sample(orgRepos));

// Shuffle the selected repos and limit to the specified number
const finalSelectedRepos = _.sampleSize(selectedRepos, limit || selectedRepos.length);

return finalSelectedRepos;
}

async function main() {
if (!config.githubToken) {
console.error("GitHub token is required. Set it using the --token option or GITHUB_TOKEN environment variable.");
Expand All @@ -137,18 +173,18 @@ async function main() {
format: ' {bar} | {percentage}% | {value}/{total} | {task}',
}, cliProgress.Presets.shades_classic);

if (argv.generate) {
const handSelectedRepos = await generateHandSelectedList(repositories, progress, argv.limit);
const outputPath = path.resolve(argv.output);
await fs.writeFile(outputPath, JSON.stringify(handSelectedRepos, null, 2));
console.log(`Generated hand-selected list with ${handSelectedRepos.length} repositories. Saved to ${outputPath}`);
return;
}

let repositoriesToProcess = repositories;
if (argv.limit) {
const unprocessedRepos = repositories.filter(repo => !progress[repo] || progress[repo].error);

// Group repositories by organization
const reposByOrg = _.groupBy(unprocessedRepos, getOrgFromRepo);

// Select one random repo from each org
const selectedRepos = Object.values(reposByOrg).map(orgRepos => _.sample(orgRepos));

// Shuffle the selected repos and limit to the specified number
repositoriesToProcess = _.sampleSize(selectedRepos, argv.limit);
repositoriesToProcess = await generateHandSelectedList(repositories, progress, argv.limit);

console.log(`Processing ${repositoriesToProcess.length} repositories from unique organizations out of ${Object.keys(reposByOrg).length} unprocessed organizations.`);

Expand Down

0 comments on commit 794e331

Please sign in to comment.