Skip to content

Commit

Permalink
DEV - clean console log
Browse files Browse the repository at this point in the history
  • Loading branch information
juliecoust committed Jan 2, 2025
1 parent d0ebe0e commit 026f05f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 22 deletions.
15 changes: 6 additions & 9 deletions src/data/data-sources/sqlite/sqlite-sample-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ export class SQLiteSampleDataSource implements SampleDataSource {
// Begin transaction
this.db.run('BEGIN TRANSACTION', (beginErr: Error) => {
if (beginErr) {
console.log("Failed to begin transaction:", beginErr);
return reject(beginErr);
return reject("Failed to begin transaction:" + beginErr);
}

const insertPromises = samples.map((sample) => {
Expand Down Expand Up @@ -238,8 +237,7 @@ export class SQLiteSampleDataSource implements SampleDataSource {

this.db.run(sql, params, function (err) {
if (err) {
console.log("Failed to insert sample:", err);
rejectInsert(err);
rejectInsert("Failed to insert sample:" + err);
} else {
insertedIds.push(this.lastID);
resolveInsert(this.lastID);
Expand All @@ -253,8 +251,7 @@ export class SQLiteSampleDataSource implements SampleDataSource {
// Commit transaction if all inserts are successful
this.db.run('COMMIT', (commitErr: Error) => {
if (commitErr) {
console.log("Failed to commit transaction:", commitErr);
return reject(commitErr);
return reject("Failed to commit transaction:" + commitErr);
}
resolve(insertedIds);
});
Expand All @@ -263,11 +260,11 @@ export class SQLiteSampleDataSource implements SampleDataSource {
// Rollback transaction if any insert fails
this.db.run('ROLLBACK', (rollbackErr: Error) => {
if (rollbackErr) {
console.log("Failed to rollback transaction:", rollbackErr);
reject("Failed to rollback transaction:" + rollbackErr);
} else {
console.log("Transaction rolled back due to error:", error);
reject("Transaction rolled back due to error:" + error);
}
reject(error);

});
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/domain/repositories/project-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,11 @@ export class ProjectRepositoryImpl implements ProjectRepository {
const zipExists = await this.checkFileExists(destSubfolder);
if (!zipExists) {
// If not, copy and zip the folder
//console.log(`Copying new folder: ${entry.name}`);
// TODO LOG IN TASK LOG FILE `Copying new folder: ${entry.name}`
await this.zipFolder(sourceSubfolder, destSubfolder);
}
// else {
// console.log(`Skipping already existing folder: ${entry.name}`);
// TODO LOG IN TASK LOG FILE `Skipping already existing folder: ${entry.name}`);
// }
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/domain/repositories/search-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export class SearchRepositoryImpl implements SearchRepository {
if (!sort_by || sort_by.slice(-1) !== ")") {
// Add an error message to the errors array
errors.push(statement);
console.log("error" + statement)
return null;
}

Expand All @@ -44,16 +43,13 @@ export class SearchRepositoryImpl implements SearchRepository {
if (!clean_sort_by || !order_by) {
// Add an error message to the errors array
errors.push(statement);
console.log("error" + statement)

return null;
}

// Check that order_by is either asc or desc
if (!this.order_by_allow_params.includes(order_by.toLowerCase())) {
// Add an error message to the errors array
errors.push(order_by);
console.log("error" + order_by)
return null;
}

Expand Down
2 changes: 0 additions & 2 deletions src/domain/repositories/task-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export class TaskRepositoryImpl implements TaskRepository {
await this.logMessage(log_file_path, "Task created for " + task.task_type)
await this.logMessage(log_file_path, "Task params: " + JSON.stringify(task.task_params))
} catch (err) {
console.log(err);
throw new Error("Cannot create log file");
}
// update task with log file path
Expand Down Expand Up @@ -349,7 +348,6 @@ export class TaskRepositoryImpl implements TaskRepository {
return data;
} catch (err) {
// if error, throw an error
console.log(err);
throw new Error("Cannot read log file");
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/domain/repositories/user-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ export class UserRepositoryImpl implements UserRepository {
return false;
} catch (error) {
// An error occurred while fetching or comparing, log the error and return false
console.log(error);
return false;
}
}
Expand All @@ -218,8 +217,6 @@ export class UserRepositoryImpl implements UserRepository {
return decoded_token
} catch (error) {
// An error occurred while fetching or comparing, log the error and return null
console.log(error);
console.log("Token invalid or expired.");
return null;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/presentation/routers/tasks-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default function TaskRouter(
const logs = await getLogFileTask.execute((req as CustomRequest).token, taskId);
res.status(200).send(logs);
} catch (err) {
console.log(err);
console.log(err)
if (err.message === "User cannot be used") res.status(403).send({ errors: [err.message] })
else if (err.message === "Cannot find task") res.status(404).send({ errors: [err.message] });
else if (err.message === "User does not have the necessary permissions to access this task.") res.status(403).send({ errors: ["Cannot get task log"] });
Expand All @@ -100,7 +100,7 @@ export default function TaskRouter(
const taskId = parseInt(req.params.task_id);
await streamZipFileUseCase.execute((req as CustomRequest).token, taskId, res);
} catch (err) {
console.log(err);
console.log(err)
if (err.message === "User cannot be used") res.status(403).send({ errors: [err.message] })
else if (err.message === "Cannot find task") res.status(404).send({ errors: [err.message] });
else if (err.message === "Cannot find task file") res.status(404).send({ errors: [err.message] });
Expand Down

0 comments on commit 026f05f

Please sign in to comment.