(ctx context.Context, repo *database.Repository)
| 122 | } |
| 123 | |
| 124 | func (rc *RecomComponent) calcQualityScore(ctx context.Context, repo *database.Repository) (float64, error) { |
| 125 | score := 0.0 |
| 126 | // get file counts from git server |
| 127 | namespace, name := repo.NamespaceAndName() |
| 128 | files, err := getFilePaths(namespace, name, "", repo.RepositoryType, rc.gs.GetRepoFileTree) |
| 129 | if err != nil { |
| 130 | return 0, fmt.Errorf("failed to get repo file tree,%w", err) |
| 131 | } |
| 132 | fileCount := len(files) |
| 133 | for _, f := range files { |
| 134 | if f == "README.md" { |
| 135 | fileCount-- |
| 136 | } |
| 137 | if f == "LICENSE" { |
| 138 | fileCount-- |
| 139 | } |
| 140 | if f == ".gitattributes" { |
| 141 | fileCount-- |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | if fileCount >= 2 { |
| 146 | score += 300.0 |
| 147 | } |
| 148 | return score, nil |
| 149 | } |
| 150 | |
| 151 | func (rc *RecomComponent) loadWeights() (map[string]string, error) { |
| 152 | ctx := context.Background() |
no test coverage detected