Skip to content

Commit

Permalink
Put demo data in individual folders
Browse files Browse the repository at this point in the history
  • Loading branch information
Malte-Hansen committed Jan 7, 2025
1 parent 07ccb1d commit 68b59ea
Show file tree
Hide file tree
Showing 19 changed files with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions demo-supplier/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ const landscapes = [];
listFilesInDirectory("demo-data");

async function listFilesInDirectory(directoryPath) {
fs.readdir(directoryPath, (err, files) => {
fs.readdir(directoryPath, (err, folders) => {
if (err) {
console.error(`Error reading directory: ${err.message}`);
return;
}

files.forEach((file) => {
const filePath = path.join(directoryPath, file);
folders.forEach((folder) => {
const filePath = path.join(directoryPath, folder);

// Check if it's a file or a directory
fs.stat(filePath, (err, stats) => {
Expand All @@ -43,8 +43,8 @@ async function listFilesInDirectory(directoryPath) {
return;
}

if (stats.isFile() && file.includes("-structure.json")) {
createLandscapeSample({ filePrefix: file.replace("-structure.json", "") });
if (stats.isDirectory()) {
createLandscapeSample({ folder: folder });
}
});
});
Expand All @@ -53,7 +53,7 @@ async function listFilesInDirectory(directoryPath) {

// Expanding PetClinic
createLandscapeSample({
filePrefix: "Petclinic Samle",
folder: "Petclinic Sample",
token: "19844195-7235-4254-a17b-0f7fb49adb0a",
alias: "Petclinic Sample (Random traces and increasing, unrelated timestamps (with random gaps))",
traceModifier: removeRandomTraces,
Expand All @@ -74,7 +74,7 @@ createLandscapeSample({

// BEGIN BIG SL Sample
createLandscapeSample({
filePrefix: "Petclinic Samle",
folder: "Petclinic Sample",
token: "1d8c9223-b790-4873-9b5d-fdf68cdc082f",
alias: "Large Landscape Sample",
initializer: (structure, traces) => {
Expand Down Expand Up @@ -120,7 +120,7 @@ createLandscapeSample({
let previousStructure = null;

createLandscapeSample({
filePrefix: "Distributed Petclinic Sample",
folder: "Distributed Petclinic Sample",
token: "12444195-6144-4254-a17b-0f7fb49adb0a",
alias: "Expanding Sample (Expanding structure and increasing, unrelated timestamps)",
structureModifier: (structureData) => {
Expand Down Expand Up @@ -194,7 +194,7 @@ function createExpressApplication(port) {
* Create a sample landscape for the ExplorViz demo.
* Loads the data and sets up express routes.
* @param {{
* filePrefix: string;
* folder: string;
* token: string;
* traceModifier?: DataModifier,
* structureModifier?: DataModifier,
Expand All @@ -203,25 +203,33 @@ function createExpressApplication(port) {
* }} options
*/
async function createLandscapeSample({
filePrefix,
folder,
token,
alias,
traceModifier,
structureModifier,
timestampModifier,
initializer,
}) {
const structureData = JSON.parse(await readFile(`demo-data/${filePrefix}-structure.json`));
const dynamicData = JSON.parse(await readFile(`demo-data/${filePrefix}-dynamic.json`));
const timestampData = JSON.parse(await readFile(`demo-data/${filePrefix}-timestamp.json`));
let structureData;
let dynamicData;
let timestampData;
try {
structureData = JSON.parse(await readFile(`demo-data/${folder}/structure.json`));
dynamicData = JSON.parse(await readFile(`demo-data/${folder}/dynamic.json`));
timestampData = JSON.parse(await readFile(`demo-data/${folder}/timestamps.json`));
} catch {
console.error("Could not read files for folder:", folder);
return;
}

const landscapeToken = token ? token : structureData.landscapeToken;

landscapes.push({
value: landscapeToken,
ownerId: "github|123456",
created: timestampData.length > 0 ? timestampData[0].epochMilli : 0,
alias: alias ? alias : filePrefix,
alias: alias ? alias : folder,
sharedUsersIds: [],
});

Expand Down

0 comments on commit 68b59ea

Please sign in to comment.