From c2e1e05416ecc1b9acf2ba8c82b6b063bfbbf8bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20So=C3=B3s?= Date: Tue, 14 Jan 2025 13:09:22 +0100 Subject: [PATCH] Remove isBlocked fields + starting to remove them from Datastore. (#8463) --- CHANGELOG.md | 2 ++ app/lib/account/models.dart | 8 ----- app/lib/package/models.dart | 10 +------ app/lib/publisher/models.dart | 12 -------- app/lib/shared/integrity.dart | 7 +++-- app/lib/shared/versions.dart | 4 +-- .../tool/backfill/backfill_new_fields.dart | 29 +++++++++++-------- 7 files changed, 26 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 014c6bb97..296e0b953 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ 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) + * Bump runtimeVersion to `2025.01.15`. + * Note: started deleting `Package.isBlocked`, `Publisher.isBlocked`, `User.isBlocked`. ## `20250114t095800-all` * Bump runtimeVersion to `2025.01.14`. diff --git a/app/lib/account/models.dart b/app/lib/account/models.dart index abf1c8125..5fa232822 100644 --- a/app/lib/account/models.dart +++ b/app/lib/account/models.dart @@ -49,14 +49,6 @@ class User extends db.ExpandoModel { @db.BoolProperty(required: true) bool isDeleted = false; - /// [isBlocked] is set when a user account is blocked (is on administrative hold). - /// When this happens user-data is preserved, but the user should not be able - /// to perform any action. - /// - /// TODO: remove after runtime version `2024.12.17` is no longer running. - @db.BoolProperty(required: false) - bool isBlocked = false; - /// `true` if user was moderated (pending moderation or deletion). @db.BoolProperty(required: true) bool isModerated = false; diff --git a/app/lib/package/models.dart b/app/lib/package/models.dart index c458e0dc8..f1c9db752 100644 --- a/app/lib/package/models.dart +++ b/app/lib/package/models.dart @@ -122,13 +122,6 @@ class Package extends db.ExpandoModel { @db.BoolProperty(required: true) bool isUnlisted = false; - /// Set to `true` if package should not be displayed anywhere, because of - /// pending moderation or deletion. - /// - /// TODO: remove after runtime version `2024.12.17` is no longer running. - @db.BoolProperty(required: false) - bool isBlocked = false; - /// `true` if package was moderated (pending moderation or deletion). @db.BoolProperty(required: true) bool isModerated = false; @@ -186,7 +179,6 @@ class Package extends db.ExpandoModel { ..likes = 0 ..isDiscontinued = false ..isUnlisted = false - ..isBlocked = false ..isModerated = false ..assignedTags = [] ..deletedVersions = []; @@ -194,7 +186,7 @@ class Package extends db.ExpandoModel { // Convenience Fields: - bool get isVisible => !isBlocked && !isModerated; + bool get isVisible => !isModerated; bool get isNotVisible => !isVisible; bool get isIncludedInRobots { diff --git a/app/lib/publisher/models.dart b/app/lib/publisher/models.dart index 44aa80733..58e82f61a 100644 --- a/app/lib/publisher/models.dart +++ b/app/lib/publisher/models.dart @@ -54,18 +54,6 @@ class Publisher extends db.ExpandoModel { @db.BoolProperty(required: true) bool isAbandoned = false; - /// [isBlocked] is set when a [Publisher] is blocked by an administrative action. - /// When this happens: - /// - The publisher page should neither be visible nor listed anywhere. - /// - Administrator roles of the publisher must not be able to change any setting, - /// membership information, or invite new members. - /// - Administrator roles of the publisher must not be able to publisher a new version - /// for packages of the publisher, or change any of the existing package's properties. - /// - /// TODO: remove after runtime version `2024.12.17` is no longer running. - @db.BoolProperty(required: false) - bool isBlocked = false; - /// `true` if publisher was moderated (pending moderation or deletion). @db.BoolProperty(required: true) bool isModerated = false; diff --git a/app/lib/shared/integrity.dart b/app/lib/shared/integrity.dart index 8ed5d8529..72d934490 100644 --- a/app/lib/shared/integrity.dart +++ b/app/lib/shared/integrity.dart @@ -39,8 +39,9 @@ final _random = math.Random.secure(); /// The presence of such fields won't be reported as integrity issue, only /// the absent ones will be reported. const _allowedUnmappedFields = { - 'Package.isWithheld', - 'Package.withheldReason', + 'Package.isBlocked', + 'Publisher.isBlocked', + 'User.isBlocked', }; /// Checks the integrity of the datastore. @@ -441,7 +442,7 @@ class IntegrityChecker { isModerated: p.isModerated, moderatedAt: p.moderatedAt, ); - if (p.isModerated || p.isBlocked) { + if (p.isModerated) { _packagesWithIsModeratedFlag.add(p.name!); } diff --git a/app/lib/shared/versions.dart b/app/lib/shared/versions.dart index 453ca78fe..aa5bf3e24 100644 --- a/app/lib/shared/versions.dart +++ b/app/lib/shared/versions.dart @@ -24,10 +24,10 @@ final RegExp runtimeVersionPattern = RegExp(r'^\d{4}\.\d{2}\.\d{2}$'); /// when the version switch happens. const _acceptedRuntimeVersions = [ // The current [runtimeVersion]. - '2025.01.14', + '2025.01.15', // Fallback runtime versions. + '2025.01.14', '2025.01.07', - '2024.12.17', ]; /// Sets the current runtime versions. diff --git a/app/lib/tool/backfill/backfill_new_fields.dart b/app/lib/tool/backfill/backfill_new_fields.dart index ac1a2011b..b05270587 100644 --- a/app/lib/tool/backfill/backfill_new_fields.dart +++ b/app/lib/tool/backfill/backfill_new_fields.dart @@ -3,7 +3,9 @@ // BSD-style license that can be found in the LICENSE file. import 'package:logging/logging.dart'; +import 'package:pub_dev/account/models.dart'; import 'package:pub_dev/package/models.dart'; +import 'package:pub_dev/publisher/models.dart'; import 'package:pub_dev/shared/datastore.dart'; final _logger = Logger('backfill_new_fields'); @@ -19,19 +21,22 @@ Future backfillNewFields() async { Future _removeKnownUnmappedFields() async { _logger.info('Removing unmapped fields...'); - await for (final p in dbService.query().run()) { - if (p.additionalProperties.isEmpty) continue; - if (p.additionalProperties.containsKey('automatedPublishingJson') || - p.additionalProperties.containsKey('blocked') || - p.additionalProperties.containsKey('blockedReason')) { - await withRetryTransaction(dbService, (tx) async { - final pkg = await tx.lookupValue(p.key); - pkg.additionalProperties.remove('automatedPublishingJson'); - pkg.additionalProperties.remove('blocked'); - pkg.additionalProperties.remove('blockedReason'); - tx.insert(pkg); - }); + + Future removeIsBlocked() async { + await for (final p in dbService.query().run()) { + if (p.additionalProperties.isEmpty) continue; + if (p.additionalProperties.containsKey('isBlocked')) { + await withRetryTransaction(dbService, (tx) async { + final e = await tx.lookupValue(p.key); + e.additionalProperties.remove('isBlocked'); + tx.insert(e); + }); + } } } + + await removeIsBlocked(); + await removeIsBlocked(); + await removeIsBlocked(); _logger.info('Removing unmapped fields completed.'); }