Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agent/app/service/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ func (f *FileService) ReadLogByLine(req request.FileReadByLineReq) (*response.Fi
if req.TaskID != "" {
opts = append(opts, taskRepo.WithByID(req.TaskID))
} else {
opts = append(opts, repo.WithByType(req.TaskType), taskRepo.WithOperate(req.TaskOperate), taskRepo.WithResourceID(req.ID))
opts = append(opts, repo.WithByType(req.TaskType), taskRepo.WithOperate(req.TaskOperate), taskRepo.WithResourceID(req.ResourceID))
}
taskModel, err := taskRepo.GetFirst(opts...)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two code files have different names, but the overall structure is almost identical as they serve the same purpose of reading log data from a File service based on a given file read line request. However, there's no direct difference identified that suggests an issue or regularity problem.

To optimize the readability and performance:

  1. Make all variables in single lines.
  2. Use string slicing to join strings instead of concatenation.
  3. Rename functions or variable names to be more descriptive.

For checking the compliance with standards over time, this should not impact anything since they're written well and do what they should: fetching the log data from the provided repository.

Expand Down
5 changes: 4 additions & 1 deletion frontend/src/routers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ router.beforeEach((to, from, next) => {
return;
}

if (to.path === '/apps/all' && to.query.install != undefined) {
return next();
}

const activeMenuKey = 'cachedRoute' + (to.meta.activeMenu || '');
const cachedRoute = localStorage.getItem(activeMenuKey);

if (
to.meta.activeMenu &&
to.meta.activeMenu != from.meta.activeMenu &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The most notable difference between the two codes is the use of localStorage.removeItem() followed by return next(); at line 47. This may cause unnecessary memory usage and should be replaced with a cleaner approach like calling an async function which will not affect cache behavior. Additionally, please ensure you follow modern naming conventions and avoid global variables or functions where reusable code has been implemented.

For example:

try {
    // Remove cached route from local storage if it exists
} catch (error) {}
return await router.push(to);  // Always push to location rather than navigating

This version uses try-catch block to prevent errors during removal. The return await statement ensures that no side effects take place in case an error arises while trying to remove the item form cache.

Expand Down
Loading