1
0
mirror of https://github.com/google/nomulus synced 2026-01-08 23:23:32 +00:00

Record domain transaction for domain deletes

This is the third of many cls adding explicit logging in all our domain
mutation flows to facilitate transaction reporting.

We add a +1 counter for either grace or nograce deletes, based on the grace period status of the domain. We then search back in time for DOMAIN_CREATE, DOMAIN_RENEW and DOMAIN_AUTORENEW HistoryEntries off the same resource that happened in their corresponding grace periods (5, 5 and 45 days respectively). All transaction records for these events are then given -1 counters to properly account for cancellations in the NET_CREATE and NET_RENEW fields.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166506010
This commit is contained in:
larryruili
2017-08-25 11:55:39 -07:00
committed by Ben McIlwain
parent d011b8e073
commit 7ee8bc9070
4 changed files with 350 additions and 60 deletions

View File

@@ -17,6 +17,7 @@ package google.registry.model.reporting;
import static com.google.common.base.Preconditions.checkArgument;
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
import com.google.common.collect.ImmutableSet;
import com.googlecode.objectify.annotation.Embed;
import google.registry.model.Buildable;
import google.registry.model.ImmutableObject;
@@ -114,6 +115,42 @@ public class DomainTransactionRecord extends ImmutableObject implements Buildabl
return nameToField("NET_RENEWS_%d_YR", years);
}
private static final ImmutableSet<TransactionReportField> ADD_FIELDS =
ImmutableSet.of(
NET_ADDS_1_YR,
NET_ADDS_2_YR,
NET_ADDS_3_YR,
NET_ADDS_4_YR,
NET_ADDS_5_YR,
NET_ADDS_6_YR,
NET_ADDS_7_YR,
NET_ADDS_8_YR,
NET_ADDS_9_YR,
NET_ADDS_10_YR);
private static final ImmutableSet<TransactionReportField> RENEW_FIELDS =
ImmutableSet.of(
NET_RENEWS_1_YR,
NET_RENEWS_2_YR,
NET_RENEWS_3_YR,
NET_RENEWS_4_YR,
NET_RENEWS_5_YR,
NET_RENEWS_6_YR,
NET_RENEWS_7_YR,
NET_RENEWS_8_YR,
NET_RENEWS_9_YR,
NET_RENEWS_10_YR);
/** Boilerplate to determine if a field is one of the NET_ADDS fields. */
public static boolean isAddsField(TransactionReportField field) {
return ADD_FIELDS.contains(field);
}
/** Boilerplate to determine if a field is one of the NET_ADDS fields. */
public static boolean isRenewsField(TransactionReportField field) {
return RENEW_FIELDS.contains(field);
}
private static TransactionReportField nameToField(String enumTemplate, int years) {
checkArgument(
years >= 1 && years <= 10, "domain add and renew years must be between 1 and 10");