(req dto.SearchWithPage)
| 741 | } |
| 742 | |
| 743 | func (a AgentService) Page(req dto.SearchWithPage) (int64, []dto.AgentItem, error) { |
| 744 | var opts []repo.DBOption |
| 745 | if strings.TrimSpace(req.Info) != "" { |
| 746 | opts = append(opts, repo.WithByLikeName(req.Info)) |
| 747 | } |
| 748 | count, list, err := agentRepo.Page(req.Page, req.PageSize, opts...) |
| 749 | if err != nil { |
| 750 | return 0, nil, err |
| 751 | } |
| 752 | items := make([]dto.AgentItem, 0, len(list)) |
| 753 | appInstalls := make([]model.AppInstall, 0, len(list)) |
| 754 | for _, item := range list { |
| 755 | appInstall, _ := appInstallRepo.GetFirst(repo.WithByID(item.AppInstallID)) |
| 756 | appInstalls = append(appInstalls, appInstall) |
| 757 | } |
| 758 | syncAgentAppInstalls(appInstalls) |
| 759 | for index, item := range list { |
| 760 | appInstall := appInstalls[index] |
| 761 | envMap := readInstallEnv(appInstall.Env) |
| 762 | agentItem := buildAgentItem(&item, &appInstall, envMap) |
| 763 | agentItem.Upgradable = checkAgentUpgradable(appInstall) |
| 764 | items = append(items, agentItem) |
| 765 | } |
| 766 | if err := hydrateAgentWebsiteItems(items); err != nil { |
| 767 | return 0, nil, err |
| 768 | } |
| 769 | return count, items, nil |
| 770 | } |
| 771 | |
| 772 | func (a AgentService) Delete(req dto.AgentDeleteReq) error { |
| 773 | agent, err := agentRepo.GetFirst(repo.WithByID(req.ID)) |
nothing calls this directly
no test coverage detected