MCPcopy Create free account
hub / github.com/OpenCSGs/csghub-server / calcQualityScore

Method calcQualityScore

component/recom.go:124–149  ·  view source on GitHub ↗
(ctx context.Context, repo *database.Repository)

Source from the content-addressed store, hash-verified

122}
123
124func (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
151func (rc *RecomComponent) loadWeights() (map[string]string, error) {
152 ctx := context.Background()

Callers 1

calcTotalScoreMethod · 0.95

Calls 2

getFilePathsFunction · 0.70
NamespaceAndNameMethod · 0.45

Tested by

no test coverage detected