Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions src/com/github/andlyticsproject/console/v2/JsonParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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);
}
}
2 changes: 1 addition & 1 deletion src/com/github/andlyticsproject/model/Revenue.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public class Revenue {

public enum Type {
TOTAL, SALES, IN_APP
TOTAL, APP_SALES, IN_APP, SUBSCRIPTIONS
}


Expand Down
2 changes: 1 addition & 1 deletion src/com/github/andlyticsproject/model/RevenueSummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down