@@ -30,10 +30,15 @@ void registerScoreCardBackend(ScoreCardBackend backend) =>
30
30
ScoreCardBackend get scoreCardBackend =>
31
31
ss.lookup (#_scorecard_backend) as ScoreCardBackend ;
32
32
33
+ /// Handles the data store and lookup for ScoreCard.
33
34
class ScoreCardBackend {
34
35
final db.DatastoreDB _db;
35
36
ScoreCardBackend (this ._db);
36
37
38
+ /// Returns the [ScoreCardData] for the given package and version.
39
+ ///
40
+ /// When [onlyCurrent] is false, it will try to load earlier versions of the
41
+ /// data.
37
42
Future <ScoreCardData > getScoreCardData (
38
43
String packageName,
39
44
String packageVersion, {
@@ -80,6 +85,9 @@ class ScoreCardBackend {
80
85
return data;
81
86
}
82
87
88
+ /// Creates or updates a [ScoreCardReport] entry with the report's [data] .
89
+ /// The [data] will be converted to json and stored as a byte in the report
90
+ /// entry.
83
91
Future updateReport (
84
92
String packageName, String packageVersion, ReportData data) async {
85
93
final key = scoreCardKey (packageName, packageVersion)
@@ -109,6 +117,7 @@ class ScoreCardBackend {
109
117
});
110
118
}
111
119
120
+ /// Load and deserialize the reports for the given package and version.
112
121
Future <Map <String , ReportData >> loadReports (
113
122
String packageName, String packageVersion,
114
123
{List <String > reportTypes}) async {
@@ -128,6 +137,8 @@ class ScoreCardBackend {
128
137
return result;
129
138
}
130
139
140
+ /// Updates the [ScoreCard] entry, reading both the package and version data,
141
+ /// alongside the data from reports, and compiles a new summary of them.
131
142
Future updateScoreCard (String packageName, String packageVersion) async {
132
143
final key = scoreCardKey (packageName, packageVersion);
133
144
final pAndPv = await _db.lookup ([key.parent, key.parent.parent]);
0 commit comments