/*
 *
 * CODENVY CONFIDENTIAL
 * ________________
 *
 * [2012] - [2013] Codenvy, S.A.
 * All Rights Reserved.
 * NOTICE: All information contained herein is, and remains
 * the property of Codenvy S.A. and its suppliers,
 * if any. The intellectual and technical concepts contained
 * herein are proprietary to Codenvy S.A.
 * and its suppliers and may be covered by U.S. and Foreign Patents,
 * patents in process, and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Codenvy S.A..
 */
package com.codenvy.analytics.metrics.users;

import com.codenvy.analytics.datamodel.LongValueData;
import com.codenvy.analytics.datamodel.ValueData;
import com.codenvy.analytics.datamodel.ValueDataUtil;
import com.codenvy.analytics.metrics.CalculatedMetric;
import com.codenvy.analytics.metrics.Context;
import com.codenvy.analytics.metrics.MetricType;

import javax.annotation.security.RolesAllowed;
import java.io.IOException;

/** @author <a href="mailto:abazko@codenvy.com">Anatoliy Bazko</a> */
@RolesAllowed({"system/admin", "system/manager"})
public class NonActiveUsers extends CalculatedMetric {

    public NonActiveUsers() {
        super(MetricType.NON_ACTIVE_USERS, new MetricType[]{MetricType.ACTIVE_USERS,
                                                            MetricType.CREATED_UNIQUE_USERS});
    }

    @Override
    public ValueData getValue(Context context) throws IOException {
        LongValueData total = ValueDataUtil.getAsLong(basedMetric[0], context);
        LongValueData active = ValueDataUtil.getAsLong(basedMetric[1], context);

        return new LongValueData(total.getAsLong() - active.getAsLong());
    }

    @Override
    public Class<? extends ValueData> getValueDataClass() {
        return LongValueData.class;
    }

    @Override
    public String getDescription() {
        return "Non-active users";
    }
}

@@ -1334,21 +1334,29 @@
 ricType.
-ACTIV
+CREATED_UNIQU
 E_USERS,
@@ -1423,37 +1423,29 @@
  MetricType.
-CREATED_UNIQU
+ACTIV
 E_USERS%7D);%0A 

Fix personal data statistics: active users