From 8f8a7000bfde70d2ab51a0b1502aae4daac434d0 Mon Sep 17 00:00:00 2001 From: Nikolay Elenkov Date: Fri, 24 May 2013 17:11:15 +0900 Subject: [PATCH] some cleanup --- .../console/v2/JsonParser.java | 23 +++++++++++++------ .../andlyticsproject/model/Revenue.java | 2 +- .../model/RevenueSummary.java | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/com/github/andlyticsproject/console/v2/JsonParser.java b/src/com/github/andlyticsproject/console/v2/JsonParser.java index dbde1a74..c905e62e 100755 --- a/src/com/github/andlyticsproject/console/v2/JsonParser.java +++ b/src/com/github/andlyticsproject/console/v2/JsonParser.java @@ -565,7 +565,6 @@ public static Revenue parseLatestTotalRevenue(String json) throws IOException { String currency = null; Date reportDate = null; Date revenueDate = null; - Date now = new Date(); String revenueType1 = null; String revenueType2 = null; double value = 0; @@ -578,8 +577,11 @@ public static Revenue parseLatestTotalRevenue(String json) throws IOException { while (reader.hasNext()) { name = reader.nextName(); // 1: sales, 2: in-app, 3: subscriptions? + // XXX this doesn't handle the case where there is more + // than one, e.g. app sales + subscriptions if ("1".equals(name) || "2".equals(name) || "3".equals(name)) { - // revenue list?? + // revenue list: date->amount + // [{"1":"1304103600000","2":{"2":234.0}},..{"1":"1304449200000","2":{"2":123.0}},...] reader.beginObject(); while (reader.hasNext()) { name = reader.nextName(); @@ -617,9 +619,7 @@ public static Revenue parseLatestTotalRevenue(String json) throws IOException { } reader.endArray(); } else if ("2".equals(name)) { - //consume - //"2":"IN_APP", - //"3":"IN_APP" + //"APP", "IN_APP", revenueType1 = reader.nextString(); } else if ("3".equals(name)) { revenueType2 = reader.nextString(); @@ -634,13 +634,22 @@ public static Revenue parseLatestTotalRevenue(String json) throws IOException { } reader.endObject(); } else if ("xsrf".equals(name)) { - // consume XSRF? + // consume XSRF reader.nextString(); } } reader.endObject(); - return new Revenue(Revenue.Type.TOTAL, revenueDate, currency, value); + // XXX what happens when there is more than one type? + Revenue.Type type = Revenue.Type.TOTAL; + if ("APP".equals(revenueType1)) { + type = Revenue.Type.APP_SALES; + } else if ("IN_APP".equals(revenueType1)) { + type = Revenue.Type.IN_APP; + } else { + type = Revenue.Type.SUBSCRIPTIONS; + } + return new Revenue(type, revenueDate, currency, value); } } diff --git a/src/com/github/andlyticsproject/model/Revenue.java b/src/com/github/andlyticsproject/model/Revenue.java index cd00f6b0..ba30c547 100755 --- a/src/com/github/andlyticsproject/model/Revenue.java +++ b/src/com/github/andlyticsproject/model/Revenue.java @@ -6,7 +6,7 @@ public class Revenue { public enum Type { - TOTAL, SALES, IN_APP + TOTAL, APP_SALES, IN_APP, SUBSCRIPTIONS } diff --git a/src/com/github/andlyticsproject/model/RevenueSummary.java b/src/com/github/andlyticsproject/model/RevenueSummary.java index 920ec5ee..10475f69 100755 --- a/src/com/github/andlyticsproject/model/RevenueSummary.java +++ b/src/com/github/andlyticsproject/model/RevenueSummary.java @@ -20,7 +20,7 @@ public static RevenueSummary createTotal(String currency, double lastDay, double public static RevenueSummary createSales(String currency, double lastDay, double last7Days, double last30Days, double overall) { - return new RevenueSummary(Revenue.Type.SALES, currency, lastDay, last7Days, last30Days, + return new RevenueSummary(Revenue.Type.APP_SALES, currency, lastDay, last7Days, last30Days, overall); }