Don't delete or "redeem" unlimited use AllocationTokens

We haven't started dealing with timing or discounts yet, but unlimited use tokens should actually be unlimited use

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=243318266
This commit is contained in:
gbrodman 2019-04-12 13:05:06 -07:00 committed by Ben McIlwain
parent 416a39b003
commit d1e3194fce
5 changed files with 44 additions and 3 deletions

View file

@ -17,6 +17,7 @@ package google.registry.tools;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static com.google.common.collect.Iterables.partition;
import static com.google.common.collect.Streams.stream;
import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE;
import static google.registry.model.ofy.ObjectifyService.ofy;
import com.beust.jcommander.Parameter;
@ -93,6 +94,7 @@ final class DeleteAllocationTokensCommand extends ConfirmingCommand
ImmutableSet<AllocationToken> tokensToDelete =
ofy().load().keys(batch).values().stream()
.filter(t -> withDomains || !t.getDomainName().isPresent())
.filter(t -> SINGLE_USE.equals(t.getTokenType()))
.filter(t -> !t.isRedeemed())
.collect(toImmutableSet());
if (!dryRun) {