Skip to content

Commit

Permalink
refactor: cleanup console.log statements in server
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbenincasa committed Nov 8, 2024
1 parent 86c5330 commit c89616a
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 70 deletions.
4 changes: 0 additions & 4 deletions server/src/api/channelsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,6 @@ export const channelsApi: RouterPluginAsyncCallback = async (fastify) => {
req.body,
);

console.log('hello');

if (isNil(result)) {
return res.status(500).send();
}
Expand Down Expand Up @@ -378,8 +376,6 @@ export const channelsApi: RouterPluginAsyncCallback = async (fastify) => {
() => req.serverCtx.channelDB.loadCondensedLineup(req.params.id),
);

console.log('hello');

if (isNil(newLineup)) {
return res.status(500).send();
}
Expand Down
4 changes: 1 addition & 3 deletions server/src/api/debugApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,7 @@ export const debugApi: RouterPluginAsyncCallback = async (fastify) => {
const result = await new LineupCreator().resolveLineup(
req.query.channelId,
);
ifDefined(result, (r) => {
console.log(r.lineup.items.length);
});
ifDefined(result, (r) => {});
return res.send(result);
},
);
Expand Down
2 changes: 0 additions & 2 deletions server/src/api/fillerListsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ export const fillerListsApi: RouterPluginAsyncCallback = async (fastify) => {
return res.status(404).send();
}

console.log('sending response');

return res.send({
id: result.uuid,
name: result.name,
Expand Down
69 changes: 35 additions & 34 deletions server/src/cli/legacyMigrateCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,41 @@ const MigratableEntities = [
'cached-images',
];

export const LegacyMigrateCommand: CommandModule<{}, LegacyMigrateCommandArgs> =
{
command: 'legacy-migrate',
describe: 'Migrate from the legacy .dizquetv database',
builder: {
legacy_path: {
type: 'string',
default: path.join(process.cwd(), '.dizquetv'),
coerce(arg: string) {
if (!existsSync(arg)) {
throw new Error(`No directory found at ${arg}`);
}
return arg;
},
},
entities: {
type: 'array',
choices: MigratableEntities,
coerce(arg) {
if (isArray(arg)) {
return arg as string[];
} else if (isString(arg)) {
return arg.split(',');
} else {
throw new Error('Bad arg');
}
},
export const LegacyMigrateCommand: CommandModule<
object,
LegacyMigrateCommandArgs
> = {
command: 'legacy-migrate',
describe: 'Migrate from the legacy .dizquetv database',
builder: {
legacy_path: {
type: 'string',
default: path.join(process.cwd(), '.dizquetv'),
coerce(arg: string) {
if (!existsSync(arg)) {
throw new Error(`No directory found at ${arg}`);
}
return arg;
},
},
handler: async (argv) => {
console.log('Migrating DB from legacy schema...');
return await new LegacyDbMigrator(
getSettings(),
argv.legacy_path,
).migrateFromLegacyDb(argv.entities);
entities: {
type: 'array',
choices: MigratableEntities,
coerce(arg) {
if (isArray(arg)) {
return arg as string[];
} else if (isString(arg)) {
return arg.split(',');
} else {
throw new Error('Bad arg');
}
},
},
};
},
handler: async (argv) => {
return await new LegacyDbMigrator(
getSettings(),
argv.legacy_path,
).migrateFromLegacyDb(argv.entities);
},
};
4 changes: 0 additions & 4 deletions server/src/cli/settings/settingsUpdateCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ export const SettingsUpdateCommand: CommandModule<
await getSettings().directUpdate((prev) => {
prev.settings = validSettings;
});

console.log(
JSON.stringify(validSettings, undefined, args.pretty ? 4 : undefined),
);
} catch (e) {
console.error(e);
}
Expand Down
4 changes: 0 additions & 4 deletions server/src/cli/settings/settingsViewCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,5 @@ export const SettingsViewCommand: CommandModule<
if (isArray(viewSettings) && !isEmpty(viewSettings)) {
viewSettings = viewSettings[0];
}

console.log(
JSON.stringify(viewSettings, null, args.pretty ? 4 : undefined),
);
},
};
3 changes: 1 addition & 2 deletions server/src/dao/channelDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,6 @@ export class ChannelDB {
return await directDbAccess()
.transaction()
.execute(async (tx) => {
console.log('in here');
await tx
.updateTable('channel')
.where('channel.uuid', '=', id)
Expand Down Expand Up @@ -677,7 +676,7 @@ export class ChannelDB {
ops,
({ operation }) => operation === 'add',
);
console.log(adds, removes);

if (!isEmpty(removes)) {
await tx
.deleteFrom('channelPrograms')
Expand Down
2 changes: 1 addition & 1 deletion server/src/dao/migrations/lineups/SlotShowIdMigration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class SlotShowIdMigration extends ChannelLineupMigration<0, 1> {
switch (slot.programming.type) {
case 'show':
await this.handleSlot(slot.programming);
console.log(slot.programming);

break;
default:
continue;
Expand Down
1 change: 0 additions & 1 deletion server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,6 @@ export async function initServer(opts: ServerOptions) {
schedule.gracefulShutdown(),
new Promise<boolean>((resolve) => {
setTimeout(() => {
console.log('here!');
resolve(false);
}, 1000);
}).then(() => {
Expand Down
12 changes: 2 additions & 10 deletions server/src/services/dynamic_channels/ScheduledRedirectOperator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class ScheduledRedirectOperator extends SchedulingOperator<ScheduledRedir

let t0 = channelStart;
while (t0 < end) {
// console.log(newItems, newOffsets);
//
// Find out how far into the channel we are. This is measured in days essentially
const since = dayjs.duration(t0.diff(channelStart));
// Then find how far into the day the redirect would start
Expand All @@ -47,7 +47,7 @@ export class ScheduledRedirectOperator extends SchedulingOperator<ScheduledRedir
);

if (!isNull(idx)) {
// console.log(idx);
//
const programStart = channelStart.add(newOffsets[idx]);
const untilRedirect = dayjs.duration(redirectStart.diff(programStart));

Expand Down Expand Up @@ -94,14 +94,6 @@ export class ScheduledRedirectOperator extends SchedulingOperator<ScheduledRedir
: t0.add(1, 'day');
}

// initial(newOffsets)?.forEach((offset, i) =>
// console.log(
// newItems[i].type,
// dayjs(channel.startTime).add(offset).format(),
// i,
// ),
// );

return Promise.resolve({
channel,
lineup: {
Expand Down
3 changes: 0 additions & 3 deletions server/src/services/health_checks/FfmpegVersionHealthCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export class FfmpegVersionHealthCheck implements HealthCheck {
const ffmpegExists = await fileExists(settings.ffmpegExecutablePath);
const ffprobeExists = await fileExists(settings.ffprobeExecutablePath);

console.log(ffmpegExists, ffprobeExists);

const warningResult = match([ffmpegExists, ffprobeExists] as const)
.with([false, true], () =>
healthCheckResult({
Expand Down Expand Up @@ -71,7 +69,6 @@ export class FfmpegVersionHealthCheck implements HealthCheck {
private isVersionValid(version: FfmpegVersionResult, app: string) {
const versionString = version.versionString;

console.log(version);
// Try to use the parsed major/minor versions first
if (!isNil(version.majorVersion) && !isNil(version.minorVersion)) {
const result = match([version.majorVersion, version.minorVersion])
Expand Down
1 change: 0 additions & 1 deletion server/src/util/logging/basicPrettyTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { once } from 'events';
import { createWriteStream } from 'fs';

export default async (options) => {
console.log(options);
const stream = createWriteStream('test.log');
await once(stream, 'open');
return stream;
Expand Down
1 change: 0 additions & 1 deletion server/src/util/runWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export function runWorker<T>(
): Promise<T> {
return queue.add<T>(
async () => {
console.log(filenameWithoutExtension);
const worker =
process.env.NODE_ENV !== 'production'
? new Worker(new URL(import.meta.resolve('tsx/cli')), {
Expand Down

0 comments on commit c89616a

Please sign in to comment.