Small fix to anomaly tracker in statsd.

If the config specifies only one past bucket for anomaly detection,
statsd doesn't want to store any past buckets since only the current
bucket being tracked in the Metrics Producer is used for deciding
if we hit the anomaly.

Test: Checked that statsd_test passes.
Change-Id: I7ca65bf7d2dfcb2d5c7d5c90f63f4a1c70fbc792
diff --git a/cmds/statsd/src/anomaly/AnomalyTracker.cpp b/cmds/statsd/src/anomaly/AnomalyTracker.cpp
index 7c5e45e..0614e42 100644
--- a/cmds/statsd/src/anomaly/AnomalyTracker.cpp
+++ b/cmds/statsd/src/anomaly/AnomalyTracker.cpp
@@ -93,6 +93,9 @@
 
 void AnomalyTracker::addPastBucket(const MetricDimensionKey& key, const int64_t& bucketValue,
                                    const int64_t& bucketNum) {
+    if (mNumOfPastBuckets == 0) {
+        return;
+    }
     flushPastBuckets(bucketNum);
 
     auto& bucket = mPastBuckets[index(bucketNum)];
@@ -107,6 +110,9 @@
 void AnomalyTracker::addPastBucket(std::shared_ptr<DimToValMap> bucketValues,
                                    const int64_t& bucketNum) {
     VLOG("addPastBucket() called.");
+    if (mNumOfPastBuckets == 0) {
+        return;
+    }
     flushPastBuckets(bucketNum);
     // Replace the oldest bucket with the new bucket we are adding.
     mPastBuckets[index(bucketNum)] = bucketValues;