Skip to content

Commit c2e1e05

Browse files
authored
Remove isBlocked fields + starting to remove them from Datastore. (#8463)
1 parent 66ba85b commit c2e1e05

File tree

7 files changed

+26
-46
lines changed

7 files changed

+26
-46
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ Important changes to data models, configuration, and migrations between each
22
AppEngine version, listed here to ease deployment and troubleshooting.
33

44
## Next Release (replace with git tag when deployed)
5+
* Bump runtimeVersion to `2025.01.15`.
6+
* Note: started deleting `Package.isBlocked`, `Publisher.isBlocked`, `User.isBlocked`.
57

68
## `20250114t095800-all`
79
* Bump runtimeVersion to `2025.01.14`.

app/lib/account/models.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,6 @@ class User extends db.ExpandoModel<String> {
4949
@db.BoolProperty(required: true)
5050
bool isDeleted = false;
5151

52-
/// [isBlocked] is set when a user account is blocked (is on administrative hold).
53-
/// When this happens user-data is preserved, but the user should not be able
54-
/// to perform any action.
55-
///
56-
/// TODO: remove after runtime version `2024.12.17` is no longer running.
57-
@db.BoolProperty(required: false)
58-
bool isBlocked = false;
59-
6052
/// `true` if user was moderated (pending moderation or deletion).
6153
@db.BoolProperty(required: true)
6254
bool isModerated = false;

app/lib/package/models.dart

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,6 @@ class Package extends db.ExpandoModel<String> {
122122
@db.BoolProperty(required: true)
123123
bool isUnlisted = false;
124124

125-
/// Set to `true` if package should not be displayed anywhere, because of
126-
/// pending moderation or deletion.
127-
///
128-
/// TODO: remove after runtime version `2024.12.17` is no longer running.
129-
@db.BoolProperty(required: false)
130-
bool isBlocked = false;
131-
132125
/// `true` if package was moderated (pending moderation or deletion).
133126
@db.BoolProperty(required: true)
134127
bool isModerated = false;
@@ -186,15 +179,14 @@ class Package extends db.ExpandoModel<String> {
186179
..likes = 0
187180
..isDiscontinued = false
188181
..isUnlisted = false
189-
..isBlocked = false
190182
..isModerated = false
191183
..assignedTags = []
192184
..deletedVersions = [];
193185
}
194186

195187
// Convenience Fields:
196188

197-
bool get isVisible => !isBlocked && !isModerated;
189+
bool get isVisible => !isModerated;
198190
bool get isNotVisible => !isVisible;
199191

200192
bool get isIncludedInRobots {

app/lib/publisher/models.dart

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,6 @@ class Publisher extends db.ExpandoModel<String> {
5454
@db.BoolProperty(required: true)
5555
bool isAbandoned = false;
5656

57-
/// [isBlocked] is set when a [Publisher] is blocked by an administrative action.
58-
/// When this happens:
59-
/// - The publisher page should neither be visible nor listed anywhere.
60-
/// - Administrator roles of the publisher must not be able to change any setting,
61-
/// membership information, or invite new members.
62-
/// - Administrator roles of the publisher must not be able to publisher a new version
63-
/// for packages of the publisher, or change any of the existing package's properties.
64-
///
65-
/// TODO: remove after runtime version `2024.12.17` is no longer running.
66-
@db.BoolProperty(required: false)
67-
bool isBlocked = false;
68-
6957
/// `true` if publisher was moderated (pending moderation or deletion).
7058
@db.BoolProperty(required: true)
7159
bool isModerated = false;

app/lib/shared/integrity.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ final _random = math.Random.secure();
3939
/// The presence of such fields won't be reported as integrity issue, only
4040
/// the absent ones will be reported.
4141
const _allowedUnmappedFields = {
42-
'Package.isWithheld',
43-
'Package.withheldReason',
42+
'Package.isBlocked',
43+
'Publisher.isBlocked',
44+
'User.isBlocked',
4445
};
4546

4647
/// Checks the integrity of the datastore.
@@ -441,7 +442,7 @@ class IntegrityChecker {
441442
isModerated: p.isModerated,
442443
moderatedAt: p.moderatedAt,
443444
);
444-
if (p.isModerated || p.isBlocked) {
445+
if (p.isModerated) {
445446
_packagesWithIsModeratedFlag.add(p.name!);
446447
}
447448

app/lib/shared/versions.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ final RegExp runtimeVersionPattern = RegExp(r'^\d{4}\.\d{2}\.\d{2}$');
2424
/// when the version switch happens.
2525
const _acceptedRuntimeVersions = <String>[
2626
// The current [runtimeVersion].
27-
'2025.01.14',
27+
'2025.01.15',
2828
// Fallback runtime versions.
29+
'2025.01.14',
2930
'2025.01.07',
30-
'2024.12.17',
3131
];
3232

3333
/// Sets the current runtime versions.

app/lib/tool/backfill/backfill_new_fields.dart

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'package:logging/logging.dart';
6+
import 'package:pub_dev/account/models.dart';
67
import 'package:pub_dev/package/models.dart';
8+
import 'package:pub_dev/publisher/models.dart';
79
import 'package:pub_dev/shared/datastore.dart';
810

911
final _logger = Logger('backfill_new_fields');
@@ -19,19 +21,22 @@ Future<void> backfillNewFields() async {
1921

2022
Future<void> _removeKnownUnmappedFields() async {
2123
_logger.info('Removing unmapped fields...');
22-
await for (final p in dbService.query<Package>().run()) {
23-
if (p.additionalProperties.isEmpty) continue;
24-
if (p.additionalProperties.containsKey('automatedPublishingJson') ||
25-
p.additionalProperties.containsKey('blocked') ||
26-
p.additionalProperties.containsKey('blockedReason')) {
27-
await withRetryTransaction(dbService, (tx) async {
28-
final pkg = await tx.lookupValue<Package>(p.key);
29-
pkg.additionalProperties.remove('automatedPublishingJson');
30-
pkg.additionalProperties.remove('blocked');
31-
pkg.additionalProperties.remove('blockedReason');
32-
tx.insert(pkg);
33-
});
24+
25+
Future<void> removeIsBlocked<T extends ExpandoModel>() async {
26+
await for (final p in dbService.query<T>().run()) {
27+
if (p.additionalProperties.isEmpty) continue;
28+
if (p.additionalProperties.containsKey('isBlocked')) {
29+
await withRetryTransaction(dbService, (tx) async {
30+
final e = await tx.lookupValue<T>(p.key);
31+
e.additionalProperties.remove('isBlocked');
32+
tx.insert(e);
33+
});
34+
}
3435
}
3536
}
37+
38+
await removeIsBlocked<Package>();
39+
await removeIsBlocked<Publisher>();
40+
await removeIsBlocked<User>();
3641
_logger.info('Removing unmapped fields completed.');
3742
}

0 commit comments

Comments
 (0)