Skip to content

Commit

Permalink
Merge pull request #110 from GeneralMagicio/setCorrectStreamingDates
Browse files Browse the repository at this point in the history
Set correct streaming dates
  • Loading branch information
aminlatifi authored Oct 28, 2024
2 parents dc067a5 + 5ab9da7 commit 4036da5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
4 changes: 3 additions & 1 deletion src/scripts/configs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import path from 'path';

export const streamStartDate = 1729500000; // should be timestamp of deploying funding pot contract in secs
export const streamStartDate = 1730196000; // Oct 29, 2024, 10am GMT
export const streamEndDate = 1793268000; // Oct 29, 2026, 10am GMT
export const streamCliff = 31536000; // 1 year in secs = 365 * 24 * 60 * 60

// The URL of the GitHub repository containing the reports
export const repoUrl = 'https://github.com/InverterNetwork/funding-pot.git';
Expand Down
7 changes: 3 additions & 4 deletions src/scripts/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/* eslint-disable no-console */
import fs from 'fs-extra';
import { streamStartDate } from './configs';
import { streamCliff, streamEndDate, streamStartDate } from './configs';
import { AppDataSource } from '../orm';
import { EarlyAccessRound } from '../entities/earlyAccessRound';
import { QfRound } from '../entities/qfRound';

const SIX_MONTH_IN_SEC = 15768000;
const ONE_YEAR_IN_SEC = 31536000;
const TWO_YEARS_IN_SEC = 63072000;

// Function to ensure directory exists or create it
export function ensureDirectoryExists(dirPath: string) {
Expand All @@ -27,8 +26,8 @@ export function toScreamingSnakeCase(str: string): string {
export function getStreamDetails(isEarlyAccess: boolean) {
return {
START: streamStartDate,
CLIFF: isEarlyAccess ? ONE_YEAR_IN_SEC : SIX_MONTH_IN_SEC,
END: streamStartDate + (isEarlyAccess ? TWO_YEARS_IN_SEC : ONE_YEAR_IN_SEC),
CLIFF: isEarlyAccess ? streamCliff : SIX_MONTH_IN_SEC,
END: isEarlyAccess ? streamEndDate : streamStartDate + ONE_YEAR_IN_SEC,
};
}

Expand Down
34 changes: 22 additions & 12 deletions src/scripts/runFundingPotService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-console */
import { exec } from 'child_process';
import { spawn } from 'child_process';
import path from 'path';
import fs from 'fs-extra';
import simpleGit from 'simple-git';
Expand Down Expand Up @@ -175,19 +175,29 @@ function execShellCommand(command: string, workingDir: string): Promise<void> {
return new Promise((resolve, reject) => {
console.info(`Executing command: "${command}" in ${workingDir}...`);

exec(command, { cwd: workingDir }, (error, stdout, stderr) => {
if (error) {
console.error(`Error executing command: ${error.message}`);
return reject(error);
}
// Split the command into the command and its arguments
const [cmd, ...args] = command.split(' ');

if (stderr) {
console.error(`stderr: ${stderr}`);
return reject(new Error(stderr));
}
// Use spawn to execute the command
const process = spawn(cmd, args, { cwd: workingDir });

// Stream stdout in real-time
process.stdout.on('data', data => {
console.log(`stdout: ${data}`);
});

console.log(`stdout: ${stdout}`);
resolve();
// Stream stderr in real-time
process.stderr.on('data', data => {
console.error(`stderr: ${data}`);
});

// Handle the process exit event
process.on('close', code => {
if (code === 0) {
resolve();
} else {
reject(new Error(`Command failed with exit code ${code}`));
}
});
});
}
Expand Down

0 comments on commit 4036da5

Please sign in to comment.