Skip to content

Commit

Permalink
Only post well recieved skins to Mastodon
Browse files Browse the repository at this point in the history
  • Loading branch information
captbaritone committed Nov 17, 2022
1 parent 6599206 commit fdd8b2f
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 106 deletions.
7 changes: 5 additions & 2 deletions packages/skin-database/data/skins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,20 +502,23 @@ export async function getSkinToPostToInstagram(): Promise<string | null> {

export async function getSkinToPostToMastodon(): Promise<string | null> {
// TODO: This does not account for skins that have been both approved and rejected
const tweetables = await knex("skins")
const postables = await knex("skins")
.leftJoin("skin_reviews", "skin_reviews.skin_md5", "=", "skins.md5")
.leftJoin("mastodon_posts", "mastodon_posts.skin_md5", "=", "skins.md5")
.leftJoin("tweets", "tweets.skin_md5", "=", "skins.md5")
.leftJoin("refreshes", "refreshes.skin_md5", "=", "skins.md5")
.where({
"mastodon_posts.id": null,
skin_type: 1,
"skin_reviews.review": "APPROVED",
"refreshes.error": null,
})
.where("likes", ">", 20)
.groupBy("skins.md5")
.orderByRaw("random()")
.limit(1);
const skin = tweetables[0];

const skin = postables[0];
if (skin == null) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/skin-database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"polygon-clipping": "^0.15.3",
"puppeteer": "^13.3.2",
"sharp": "^0.28.3",
"sqlite3": "^5.0.2",
"sqlite3": "^5.1.2",
"temp": "^0.9.0",
"ts-node": "^10.5.0",
"twit": "^2.2.11",
Expand Down
Loading

0 comments on commit fdd8b2f

Please sign in to comment.