Skip to content

Commit

Permalink
Calculate sandboxed PackageView.isPendig from task status. (#6881)
Browse files Browse the repository at this point in the history
* Calculate sandboxed PackageView.isPendig from task status.

* Bump runtimeVersion
  • Loading branch information
isoos authored Aug 4, 2023
1 parent 098f75a commit 46e2d43
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Important changes to data models, configuration, and migrations between each
AppEngine version, listed here to ease deployment and troubleshooting.

## Next Release (replace with git tag when deployed)
* Bumped runtimeVersion to `2023.08.04`.

## `20230727t102500-all`
* Bumped runtimeVersion to `2023.07.27`.
Expand Down
25 changes: 16 additions & 9 deletions app/lib/package/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import 'package:_pub_shared/search/tags.dart';
import 'package:clock/clock.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:pana/models.dart';
import 'package:pub_dev/shared/popularity_storage.dart';
import 'package:pub_semver/pub_semver.dart';

import '../package/model_properties.dart';
Expand All @@ -20,8 +19,10 @@ import '../search/search_service.dart' show ApiPageRef;
import '../shared/datastore.dart' as db;
import '../shared/exceptions.dart';
import '../shared/model_properties.dart';
import '../shared/popularity_storage.dart';
import '../shared/urls.dart' as urls;
import '../shared/utils.dart';
import '../task/models.dart';

part 'models.g.dart';

Expand Down Expand Up @@ -949,14 +950,20 @@ class PackageView extends Object with FlagMixin {
List<ApiPageRef>? apiPages,
}) {
final hasPanaReport = scoreCard?.hasPanaReport ?? false;
final isPending =
// Job processing has not created any card yet.
(scoreCard == null) ||
// The uploader has recently removed the "discontinued" flag, but the
// analysis did not complete yet.
(scoreCard.isDiscontinued && !package.isDiscontinued) ||
// No blocker for analysis, but no results yet.
(!scoreCard.isSkipped && !hasPanaReport);
final taskStatus = scoreCard?.taskStatus;
bool isPending = false;
if (taskStatus != null) {
isPending = taskStatus == PackageVersionStatus.pending;
} else {
isPending =
// Job processing has not created any card yet.
(scoreCard == null) ||
// The uploader has recently removed the "discontinued" flag, but the
// analysis did not complete yet.
(scoreCard.isDiscontinued && !package.isDiscontinued) ||
// No blocker for analysis, but no results yet.
(!scoreCard.isSkipped && !hasPanaReport);
}

final tags = <String>{
...package.getTags(),
Expand Down
1 change: 1 addition & 0 deletions app/lib/scorecard/backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ class ScoreCardBackend {
documentationSection: null, // already embedded in summary
),
panaReport: PanaReport.fromSummary(summary, packageStatus: status),
taskStatus: versionInfo?.status,
);
if (cacheEntry != null) {
await cacheEntry.set(data);
Expand Down
3 changes: 3 additions & 0 deletions app/lib/scorecard/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:clock/clock.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:logging/logging.dart';
import 'package:pana/models.dart';
import 'package:pub_dev/task/models.dart';
import 'package:pub_semver/pub_semver.dart';

import '../dartdoc/models.dart';
Expand Down Expand Up @@ -159,6 +160,7 @@ class ScoreCardData extends Object with FlagMixin {
final DateTime? packageVersionCreated;
final DartdocReport? dartdocReport;
final PanaReport? panaReport;
final PackageVersionStatus? taskStatus;

ScoreCardData({
this.packageName,
Expand All @@ -169,6 +171,7 @@ class ScoreCardData extends Object with FlagMixin {
this.packageVersionCreated,
this.dartdocReport,
this.panaReport,
this.taskStatus,
});

factory ScoreCardData.fromJson(Map<String, dynamic> json) =>
Expand Down
10 changes: 10 additions & 0 deletions app/lib/scorecard/models.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/lib/shared/versions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ final RegExp runtimeVersionPattern = RegExp(r'^\d{4}\.\d{2}\.\d{2}$');
/// when the version switch happens.
const acceptedRuntimeVersions = <String>[
// The current [runtimeVersion].
'2023.07.27',
'2023.08.04',
// Fallback runtime versions.
'2023.07.27',
'2023.07.24',
'2023.07.06',
];

/// Represents a combined version of the overall toolchain and processing,
Expand Down
1 change: 1 addition & 0 deletions app/test/scorecard/report_size_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ void main() {
},
'urlProblems': []
},
'taskStatus': null,
});
},
processJobsWithFakeRunners: true,
Expand Down

0 comments on commit 46e2d43

Please sign in to comment.