Skip to content

Instantly share code, notes, and snippets.

@nathanchicken
Created June 12, 2023 08:49
Show Gist options
  • Save nathanchicken/6e26e3f369e6ec64215585ba62dc7adc to your computer and use it in GitHub Desktop.
Save nathanchicken/6e26e3f369e6ec64215585ba62dc7adc to your computer and use it in GitHub Desktop.
const schemas = [
{
id: 'c5b54d6d-0c7c-473b-886f-ab18c933035a',
handle: 'horizons',
name: 'Horizons',
terms: [
'0b1c29c2-5403-4c53-b41f-2653c9dfe6c9',
'71f8c1de-21e1-4892-9933-f0a06fc78840',
'e8ac58ab-e67a-4bd4-9b1c-28888ac3a673'
]
},
{
id: '92b29859-2760-457b-a9b4-5949b33bf8f5',
handle: 'innovation-stage',
name: 'Innovation Stage',
terms: [
'8b9083ab-5dec-4cbf-b730-0900a229bd99',
'd4078989-c291-44c2-8962-878561e848ee',
'9c345508-3d56-44da-8617-42487cba0a26',
'e4644ab0-0fda-400f-a7ad-54b1eccab543',
'f90c9966-8607-4e78-a1a5-44cfd6b857a3'
]
},
{
id: '21081670-668c-48ce-8e14-199b3b3b38b6',
handle: 'customer-type',
name: 'Customer type',
terms: [
'a9217085-2668-4c35-9f0a-64f2104de63a',
'026b2165-91a2-4fcd-91c8-e4d6b45e4d83',
'65b96ecd-d1fa-40c8-af67-6d05daa86898'
]
},
{
id: 'e31ebe53-c018-4bf8-bf87-b31fd61996cf',
handle: 'technology-type',
name: 'Technology type',
terms: [
'3d054ff0-9f6c-43a8-a1ec-505cb27dc2b8',
'4dc77624-4e08-418d-9bfa-c1e939818a0d',
'6e2362a5-8893-4506-8dba-f2c15ee97174',
'2d4aa2a7-87ee-46f2-9cec-e0da770dd302',
'feb25865-c9cd-4e6c-bf6c-8dc49fbd6c18',
'289e9ea5-2687-4597-b795-9d1ce8069e42',
'706ab1c0-0f59-4ebe-a517-dd3ca4b34aab'
]
},
{
id: '52fe8f9f-83ee-477d-9386-0c882b1bdf5e',
handle: 'risk-level',
name: 'Risk level',
terms: [
'3abd2cac-483b-42e6-a835-2c18be57a734',
'726c321c-f492-4e0b-bac6-a51f88844865',
'ba6a689e-52dc-4873-aaf8-c048461dfcfa'
]
},
{
id: 'd3facab8-d1da-43da-92d6-0e7b13e5f6b2',
handle: 'strategic-theme',
name: 'Strategic theme',
terms: [
'eb77e9e9-9ab0-45e2-a918-09e41f04175d',
'd6be0291-6dee-49a8-bd29-1251a573ea5e',
'87c66aff-2158-4aef-aca4-3df4f539b33a',
'48023fb0-c3a7-46d6-9b6e-e13ab89847da',
'bacdc166-b00f-4afc-a9b4-b3f6319071bf'
]
},
{
id: 'a976b2a0-48d7-44d6-86ba-cbd8cb382344',
handle: 'team',
name: 'Team',
terms: [
'3005303e-33aa-466e-8329-3f9ad32ca5bc',
'717cc6c7-28ab-4ed8-be68-047264ba7344',
'56675d38-e5a5-4981-ad13-188f2d5716a4',
'428922a7-fa1b-4042-ad93-63fb04a33008',
'88b5865c-c10e-412d-a7f9-b1ab805c32ce'
]
}
]
const words =
`Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.`.split(
' '
)
function getRandomInt (min, max) {
min = Math.ceil(min)
max = Math.floor(max)
return Math.floor(Math.random() * (max - min + 1)) + min
}
const randomWord = () => words[getRandomInt(0, words.length - 1)]
const randomTitle = (m = 5) =>
new Array(getRandomInt(3, m)).fill(null).map(randomWord).join(' ')
const randomTerms = terms => {
const offset = getRandomInt(1, terms.length)
return new Array(getRandomInt(0, terms.length)).fill(null).map((v, i) => {
return terms[(offset + i) % terms.length]
})
}
const makeIdea = async () => {
const ideaTitle = randomTitle()
const ideaSummary = randomTitle(20)
const idea = await fetch(
'https://portfolio-perf.staging.pollen8.io/api/spaces/transform/ideas.json',
{
headers: {
accept: '*/*',
'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
'cache-control': 'no-cache',
'content-type': 'application/json',
pragma: 'no-cache',
'sec-ch-ua':
'"Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'x-csrf-token':
'lo1dwLJgWjTJcvvfBKtRFOc1FXoiJxJby76f95FPHlAH4UrYJxJyVCaKDBuGwWGw--BffesjnE9c3K8z2HirFQvQ%3D%3D'
},
referrer:
'https://portfolio-perf.staging.pollen8.io/transform/portfolios/live-ventures/venture/add',
referrerPolicy: 'strict-origin-when-cross-origin',
body: `{"idea":{"title":"${ideaTitle}","handle":"","summary":"${ideaSummary}","description":"","banner_image":"","video":"","thumbnail_url":"","programme":{},"programme_handle":null,"cohort":{},"cohort_handle":null,"application":{},"members":[],"completed_steps":[],"tags":[],"feedback":{},"featured":false,"status":"venture","portfolio_handle":"live-ventures"}}`,
method: 'POST',
mode: 'cors',
credentials: 'include'
}
).then(b => b.json())
const { handle } = idea
let promises = []
schemas
.filter(() => {
return Math.round(Math.random())
})
.forEach(schema => {
const terms = randomTerms(schema.terms).map(a => ({ id: a }))
const path = `https://portfolio-perf.staging.pollen8.io/api/spaces/transform/ideas/${handle}/idea_schemas/${schema.handle}/characteristic.json`
const body = `{"characteristic":{"terms":${JSON.stringify(terms)}}}`
promises.push(
fetch(path, {
headers: {
accept: '*/*',
'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
'cache-control': 'no-cache',
'content-type': 'application/json',
pragma: 'no-cache',
'sec-ch-ua':
'"Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'x-csrf-token':
'lo1dwLJgWjTJcvvfBKtRFOc1FXoiJxJby76f95FPHlAH4UrYJxJyVCaKDBuGwWGw--BffesjnE9c3K8z2HirFQvQ%3D%3D'
},
referrer:
'https://portfolio-perf.staging.pollen8.io/transform/portfolios/live-ventures/kanban',
referrerPolicy: 'strict-origin-when-cross-origin',
body,
method: 'POST',
mode: 'cors',
credentials: 'include'
})
)
})
await Promise.all(promises)
}
const loop = async () => {
await makeIdea()
return loop()
}
// Uncomment and it'll probably work
// loop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment