Skip to content

Commit

Permalink
category-cycles: allow running for other wikis
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharthvp committed Oct 16, 2024
1 parent a84af51 commit 4a08492
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
7 changes: 6 additions & 1 deletion category-cycles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

Used to generate [User:SDZeroBot/Category_cycles](https://en.wikipedia.org/wiki/User:SDZeroBot/Category_cycles).

Run using `bash run.sh`.
Run using `bash run.sh`.

To run for a wiki other than enwiki, pass in the environment variables:
* DB
* API_URL
* OAUTH2_ACCESS_TOKEN

Files:
- get_edges.sql: Get a list of all parentcat—subcat connections through the database, with only the category page IDs for efficiency in the next step.
Expand Down
8 changes: 8 additions & 0 deletions category-cycles/prettify.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ const PAGE_LEAD = `{{User:SDZeroBot/Category cycles/header}}\n`;

process.chdir(__dirname);

// Allow running for other wikis as well
if (process.env.apiUrl) {
bot.setOptions({
apiUrl: process.env.API_URL,
OAuth2AccessToken: process.env.OAUTH2_ACCESS_TOKEN
});
}

// sort cycles by length as we're more interested in the smaller cycles
let cycles = require('./cycles.json').sort((a, b) => a.length - b.length);

Expand Down
2 changes: 1 addition & 1 deletion category-cycles/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

cd "./SDZeroBot/category-cycles"

cat get_edges.sql | sql enwiki --skip-column-names > edges.out
cat get_edges.sql | sql "${DB:-enwiki}" --skip-column-names > edges.out
echo "Got edges\n"

# add a -1 at the end for the cpp program to detect end of input
Expand Down

0 comments on commit 4a08492

Please sign in to comment.