@@ -101,60 +101,84 @@ const generateScope = async ({ octokit, orgs, scope, maxRequestInParallel }) =>
101
101
const generateScores = async ( { scope, database : currentDatabase , maxRequestInParallel, reportTagsEnabled, renderBadge, reportTool } ) => {
102
102
// @TODO : Improve deep clone logic
103
103
const database = JSON . parse ( JSON . stringify ( currentDatabase ) )
104
- const platform = 'github.com'
104
+ // const platform = 'github.com'
105
105
106
- // @TODO : End the action if there are no projects in scope?
106
+ // // @TODO : End the action if there are no projects in scope?
107
107
108
- const orgs = Object . keys ( scope [ platform ] )
109
- core . debug ( `Total Orgs/Users in scope: ${ orgs . length } ` )
108
+ // const orgs = Object.keys(scope[platform])
109
+ // core.debug(`Total Orgs/Users in scope: ${orgs.length}`)
110
110
111
- // Structure Projects
112
- const projects = [ ]
111
+ // // Structure Projects
112
+ // const projects = []
113
113
114
- orgs . forEach ( ( org ) => {
115
- const repos = scope [ platform ] [ org ] . included
116
- repos . forEach ( ( repo ) => projects . push ( { org, repo } ) )
117
- } )
114
+ // orgs.forEach((org) => {
115
+ // const repos = scope[platform][org].included
116
+ // repos.forEach((repo) => projects.push({ org, repo }))
117
+ // })
118
118
119
- core . debug ( `Total Projects in scope: ${ projects . length } ` )
119
+ // core.debug(`Total Projects in scope: ${projects.length}`)
120
120
121
- const chunks = chunkArray ( projects , maxRequestInParallel )
122
- core . debug ( `Total chunks: ${ chunks . length } ` )
121
+ // const chunks = chunkArray(projects, maxRequestInParallel)
122
+ // core.debug(`Total chunks: ${chunks.length}`)
123
123
124
- const scores = [ ]
124
+ // const scores = []
125
125
126
- for ( let index = 0 ; index < chunks . length ; index ++ ) {
127
- const chunk = chunks [ index ]
128
- core . debug ( `Processing chunk ${ index + 1 } /${ chunks . length } ` )
126
+ // for (let index = 0; index < chunks.length; index++) {
127
+ // const chunk = chunks[index]
128
+ // core.debug(`Processing chunk ${index + 1}/${chunks.length}`)
129
129
130
- const chunkScores = await Promise . all ( chunk . map ( async ( { org, repo } ) => {
131
- const { score, date, commit } = await getProjectScore ( { platform, org, repo } )
132
- core . debug ( `Got project score for ${ platform } /${ org } /${ repo } : ${ score } (${ date } )` )
130
+ // const chunkScores = await Promise.all(chunk.map(async ({ org, repo }) => {
131
+ // const { score, date, commit } = await getProjectScore({ platform, org, repo })
132
+ // core.debug(`Got project score for ${platform}/${org}/${repo}: ${score} (${date})`)
133
133
134
- const storedScore = getScore ( { database, platform, org, repo } )
134
+ // const storedScore = getScore({ database, platform, org, repo })
135
135
136
- const scoreData = { platform, org, repo, score, date, commit }
137
- // If no stored score then record if score is different then:
138
- if ( ! storedScore || storedScore . score !== score ) {
139
- saveScore ( { database, platform, org, repo, score, date, commit } )
140
- }
136
+ // const scoreData = { platform, org, repo, score, date, commit }
137
+ // // If no stored score then record if score is different then:
138
+ // if (!storedScore || storedScore.score !== score) {
139
+ // saveScore({ database, platform, org, repo, score, date, commit })
140
+ // }
141
+
142
+ // // Add previous score and date if available to the report
143
+ // if (storedScore) {
144
+ // scoreData.prevScore = storedScore.score
145
+ // scoreData.prevDate = storedScore.date
146
+ // scoreData.prevCommit = storedScore.commit
147
+
148
+ // if (storedScore.score !== score) {
149
+ // scoreData.currentDiff = parseFloat((score - storedScore.score).toFixed(1))
150
+ // }
151
+ // }
152
+
153
+ // return scoreData
154
+ // }))
155
+
156
+ // scores.push(...chunkScores)
157
+ // }
158
+
159
+ let localScores = await getLocalScores ( scoredata )
141
160
142
- // Add previous score and date if available to the report
143
- if ( storedScore ) {
144
- scoreData . prevScore = storedScore . score
145
- scoreData . prevDate = storedScore . date
146
- scoreData . prevCommit = storedScore . commit
161
+ const scores = localScores . map ( ( { score, date, commit, platform, org, repo } ) => {
162
+ const storedScore = getScore ( { database, platform, org, repo } )
163
+ const scoreData = { platform, org, repo, score, date, commit }
147
164
148
- if ( storedScore . score !== score ) {
149
- scoreData . currentDiff = parseFloat ( ( score - storedScore . score ) . toFixed ( 1 ) )
165
+ if ( ! storedScore || storedScore . score !== score ) {
166
+ saveScore ( { database , platform , org , repo , score, date , commit } )
150
167
}
151
- }
152
168
153
- return scoreData
154
- } ) )
169
+ // Add previous score and date if available to the report
170
+ if ( storedScore ) {
171
+ scoreData . prevScore = storedScore . score
172
+ scoreData . prevDate = storedScore . date
173
+ scoreData . prevCommit = storedScore . commit
155
174
156
- scores . push ( ...chunkScores )
157
- }
175
+ if ( storedScore . score !== score ) {
176
+ scoreData . currentDiff = parseFloat ( ( score - storedScore . score ) . toFixed ( 1 ) )
177
+ }
178
+ }
179
+
180
+ return scoreData
181
+ } )
158
182
159
183
core . debug ( 'All the scores are already collected' )
160
184
@@ -171,3 +195,18 @@ module.exports = {
171
195
generateScope,
172
196
generateScores
173
197
}
198
+
199
+ let scoredata = require ( '../results.json' )
200
+
201
+ const getLocalScores = async ( scores ) => {
202
+ return scores . map ( ( x ) => {
203
+ const parts = x . repo . name . split ( '/' ) ;
204
+ score = x . score
205
+ date = x . date
206
+ commit = x . repo . commit
207
+ platform = parts [ 0 ]
208
+ org = parts [ 1 ]
209
+ repo = parts [ 2 ]
210
+ return { score, date, commit, platform, org, repo }
211
+ } )
212
+ }
0 commit comments