Skip to content

Commit

Permalink
chore: adapt data generation category labels to be able to see origin…
Browse files Browse the repository at this point in the history
…: global, organisation, community
  • Loading branch information
dmijatovic committed Nov 19, 2024
1 parent 9f4f4c7 commit 5682177
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions data-generation/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ async function generateCategories(idsCommunities, idsOrganisations, maxDepth = 3
async function generateAndSaveCategoriesForEntity(idCommunity, idOrganisation, maxDepth) {
return new Promise(async res => {
let parentIdsAndFlags = [
{id: null, forSoftware: faker.datatype.boolean(), forProjects: faker.datatype.boolean()},
{id: null, forSoftware: faker.datatype.boolean(), forProjects: idCommunity ? false : faker.datatype.boolean()},
];
const idsAndFlags = [];
for (let level = 1; level <= maxDepth; level++) {
Expand All @@ -347,8 +347,17 @@ async function generateAndSaveCategoriesForEntity(idCommunity, idOrganisation, m
toGenerateCount += 1;
}
for (let i = 0; i < toGenerateCount; i++) {
const name = `Parent ${parent.id}, level ${level}, item ${i + 1}`;
const shortName = `Level ${level}, item ${i + 1}`;
let name = `Global, level ${level}, item ${i + 1}${parent.id ? `, parent${parent.id.substring(0,5)}` : ""}`;
let shortName = `G-${level}-${i + 1}${parent.id ? `, P-${parent.id.substring(0,5)}` : ""}`;

if (idCommunity){
name = `Level ${level}, item ${i + 1}, community-${idCommunity.substring(0,5)}${parent.id ? `, parent-${parent.id.substring(0,5)}` : ""}`;
shortName = `L-${level}-${i + 1}, C-${idCommunity.substring(0,5)}${parent.id ? `, P-${parent.id.substring(0,5)}` : ""}`;
}else if (idOrganisation){
name = `Level ${level}, item ${i + 1}, organisation-${idOrganisation.substring(0,5)}${parent.id ? `, parent-${parent.id.substring(0,5)}` : ""}`;
shortName = `L-${level}-${i + 1}, O-${idOrganisation.substring(0,5)}${parent.id ? `, P-${parent.id.substring(0,5)}` : ""}`;
}

const body = {
community: idCommunity,
organisation: idOrganisation,
Expand Down

0 comments on commit 5682177

Please sign in to comment.