Ghost/ghost/data-generator/lib/importers/WebMentionsImporter.js
Simon Backx d2cb23c3fa
Wired up Docker setup script and increased data generation performance (#19420)
ref PROD-233

- Stored whether Docker is used in the config files
- When running `yarn setup`, any existing Docker container will be
reset. Run with `-y` to skip the confirmation step.
- `yarn setup` will always init the database and generate fake data
- Increased amount of default generated data to 100,000 members + 500
posts.
- Made lots of performance improvements in the data generator so we can
generate the default data in ±170s
2024-01-05 13:42:30 +00:00

43 lines
1.5 KiB
JavaScript

const TableImporter = require('./TableImporter');
const {faker} = require('@faker-js/faker');
const dateToDatabaseString = require('../utils/database-date');
class WebMentionsImporter extends TableImporter {
static table = 'mentions';
static dependencies = [];
defaultQuantity = 23;
constructor(knex, transaction, {baseUrl}) {
super(WebMentionsImporter.table, knex, transaction);
this.baseUrl = baseUrl;
}
generate() {
const id = this.fastFakeObjectId();
const author = `${faker.name.fullName()}`;
// Generating only incoming recommendations for now, since we don't use webmentions for other things atm
return {
id,
source: `${faker.internet.url()}/.well-known/recommendations.json`,
source_title: faker.lorem.sentence(5),
source_site_title: `${author}'s ${faker.word.noun()}`,
source_excerpt: faker.lorem.paragraph(),
source_author: author,
source_featured_image: `https://api.dicebear.com/5.x/shapes/png?size=256&seed=${id}`,
source_favicon: `https://api.dicebear.com/5.x/bottts/png?size=32&seed=${id}`,
target: `${this.baseUrl}`,
resource_id: null,
resource_type: null,
created_at: dateToDatabaseString(faker.date.past()),
payload: JSON.stringify({}),
deleted: 0,
verified: 1
};
}
}
module.exports = WebMentionsImporter;