diff --git a/TelemetryDeckWidget/MockData.swift b/TelemetryDeckWidget/MockData.swift index afb5973..8ca1ef7 100644 --- a/TelemetryDeckWidget/MockData.swift +++ b/TelemetryDeckWidget/MockData.swift @@ -1,807 +1,237 @@ // -// File.swift +// MockData.swift // File // // Created by Charlotte Böhm on 05.10.21. // -import Foundation import DataTransferObjects +import Foundation -let insightCalculationResults = [ -""" - { - "insight" : { - "id" : "36ECF853-7651-40C1-BABF-6ED06324C16A", - "filters" : { +private func generateResultData(type: DTOv2.Insight.InsightType, granularity: QueryGranularity) -> [DTOv2.InsightCalculationResultRow] { + var returnValue: [DTOv2.InsightCalculationResultRow] = [] - }, - "groupID" : "D0DAB332-3C26-46BE-98EF-D828587292D0", - "uniqueUser" : false, - "title" : "Active Users by Month", - "widgetable" : true, - "groupBy" : "month", - "lastRunAt" : "2021-10-05T11:30:36Z", - "order" : 1, - "lastRunTime" : 0.47125601768493652, - "displayMode" : "raw", - "isExpanded" : false - }, - "calculationDuration" : 0.47125601768493652, - "id" : "36ECF853-7651-40C1-BABF-6ED06324C16A", - "calculatedAt" : "2021-10-05T11:30:36Z", - "data" : [ - { - "xAxisValue" : "2021-08-01T00:00:00.000Z", - "yAxisValue" : 5244 - }, - { - "xAxisValue" : "2021-09-01T00:00:00.000Z", - "yAxisValue" : 5567 - }, - { - "xAxisValue" : "2021-10-01T00:00:00.000Z", - "yAxisValue" : 1422 + switch type { + case .timeseries: + var previousValue: Int64 = 7000 + for date in (granularity == .day) ? dailyDates : monthlyDates { + previousValue += Int64.random(in: 0 ..< 100) + returnValue.append(DTOv2.InsightCalculationResultRow(xAxisValue: date, yAxisValue: previousValue)) + } + case .topN: + for value in breakdownKeyValues { + returnValue.append(DTOv2.InsightCalculationResultRow(xAxisValue: value, yAxisValue: Int64.random(in: 1000 ..< 10000))) + } + default: + returnValue = [] } - ] -} -""", -""" -{ - "id" : "C8DB1A2A-40DE-40F8-A4DD-741F3D97F9F3", - "calculationDuration" : 0.52053999900817871, - "insight" : { - "id" : "C8DB1A2A-40DE-40F8-A4DD-741F3D97F9F3", - "accentColor" : "C2CBCE", - "filters" : { - }, - "groupID" : "D0DAB332-3C26-46BE-98EF-D828587292D0", - "uniqueUser" : true, - "title" : "Signals by Day", - "order" : 0, - "lastRunAt" : "2021-10-05T11:30:36Z", - "groupBy" : "day", - "displayMode" : "lineChart", - "widgetable" : true, - "lastRunTime" : 0.52053999900817871, - "isExpanded" : false - }, - "calculatedAt" : "2021-10-05T11:30:36Z", - "data" : [ - { - "xAxisValue" : "2021-08-31T00:00:00.000Z", - "yAxisValue" : 37 - }, - { - "xAxisValue" : "2021-09-01T00:00:00.000Z", - "yAxisValue" : 42 - }, - { - "xAxisValue" : "2021-09-02T00:00:00.000Z", - "yAxisValue" : 33 - }, - { - "xAxisValue" : "2021-09-03T00:00:00.000Z", - "yAxisValue" : 32 - }, - { - "xAxisValue" : "2021-09-04T00:00:00.000Z", - "yAxisValue" : 36 - }, - { - "xAxisValue" : "2021-09-05T00:00:00.000Z", - "yAxisValue" : 39 - }, - { - "xAxisValue" : "2021-09-06T00:00:00.000Z", - "yAxisValue" : 36 - }, - { - "xAxisValue" : "2021-09-07T00:00:00.000Z", - "yAxisValue" : 51 - }, - { - "xAxisValue" : "2021-09-08T00:00:00.000Z", - "yAxisValue" : 38 - }, - { - "xAxisValue" : "2021-09-09T00:00:00.000Z", - "yAxisValue" : 37 - }, - { - "xAxisValue" : "2021-09-10T00:00:00.000Z", - "yAxisValue" : 37 - }, - { - "xAxisValue" : "2021-09-11T00:00:00.000Z", - "yAxisValue" : 26 - }, - { - "xAxisValue" : "2021-09-12T00:00:00.000Z", - "yAxisValue" : 35 - }, - { - "xAxisValue" : "2021-09-13T00:00:00.000Z", - "yAxisValue" : 40 - }, - { - "xAxisValue" : "2021-09-14T00:00:00.000Z", - "yAxisValue" : 30 - }, - { - "xAxisValue" : "2021-09-15T00:00:00.000Z", - "yAxisValue" : 37 - }, - { - "xAxisValue" : "2021-09-16T00:00:00.000Z", - "yAxisValue" : 46 - }, - { - "xAxisValue" : "2021-09-17T00:00:00.000Z", - "yAxisValue" : 33 - }, - { - "xAxisValue" : "2021-09-18T00:00:00.000Z", - "yAxisValue" : 41 - }, - { - "xAxisValue" : "2021-09-19T00:00:00.000Z", - "yAxisValue" : 33 - }, - { - "xAxisValue" : "2021-09-20T00:00:00.000Z", - "yAxisValue" : 42 - }, - { - "xAxisValue" : "2021-09-21T00:00:00.000Z", - "yAxisValue" : 50 - }, - { - "xAxisValue" : "2021-09-22T00:00:00.000Z", - "yAxisValue" : 56 - }, - { - "xAxisValue" : "2021-09-23T00:00:00.000Z", - "yAxisValue" : 60 - }, - { - "xAxisValue" : "2021-09-24T00:00:00.000Z", - "yAxisValue" : 46 - }, - { - "xAxisValue" : "2021-09-25T00:00:00.000Z", - "yAxisValue" : 67 - }, - { - "xAxisValue" : "2021-09-26T00:00:00.000Z", - "yAxisValue" : 61 - }, - { - "xAxisValue" : "2021-09-27T00:00:00.000Z", - "yAxisValue" : 63 - }, - { - "xAxisValue" : "2021-09-28T00:00:00.000Z", - "yAxisValue" : 61 - }, - { - "xAxisValue" : "2021-09-29T00:00:00.000Z", - "yAxisValue" : 69 - }, - { - "xAxisValue" : "2021-09-30T00:00:00.000Z", - "yAxisValue" : 61 - }, - { - "xAxisValue" : "2021-10-01T00:00:00.000Z", - "yAxisValue" : 71 - }, - { - "xAxisValue" : "2021-10-02T00:00:00.000Z", - "yAxisValue" : 66 - }, - { - "xAxisValue" : "2021-10-03T00:00:00.000Z", - "yAxisValue" : 73 - }, - { - "xAxisValue" : "2021-10-04T00:00:00.000Z", - "yAxisValue" : 70 - }, - { - "xAxisValue" : "2021-10-05T00:00:00.000Z", - "yAxisValue" : 40 - } - ] + return returnValue } -""", -""" -{ - "insight" : { - "id" : "025B8420-E688-4826-B3A7-8F5497C277EE", - "accentColor" : "E0A4C3", - "filters" : { - }, - "groupID" : "D0DAB332-3C26-46BE-98EF-D828587292D0", - "uniqueUser" : false, - "title" : "Custom Query Insight", - "order" : 0, - "groupBy" : "day", - "widgetable" : false, - "displayMode" : "barChart", - "lastRunTime" : 0.52057492733001709, - "lastRunAt" : "2021-10-05T11:30:36Z", - "isExpanded" : false - }, - "calculationDuration" : 0.52057492733001709, - "id" : "025B8420-E688-4826-B3A7-8F5497C277EE", - "calculatedAt" : "2021-10-05T11:30:36Z", - "data" : [ - { - "xAxisValue" : "2021-08-31T00:00:00.000Z", - "yAxisValue" : 163 - }, - { - "xAxisValue" : "2021-09-01T00:00:00.000Z", - "yAxisValue" : 175 - }, - { - "xAxisValue" : "2021-09-02T00:00:00.000Z", - "yAxisValue" : 120 - }, - { - "xAxisValue" : "2021-09-03T00:00:00.000Z", - "yAxisValue" : 141 - }, - { - "xAxisValue" : "2021-09-04T00:00:00.000Z", - "yAxisValue" : 125 - }, - { - "xAxisValue" : "2021-09-05T00:00:00.000Z", - "yAxisValue" : 158 - }, - { - "xAxisValue" : "2021-09-06T00:00:00.000Z", - "yAxisValue" : 154 - }, - { - "xAxisValue" : "2021-09-07T00:00:00.000Z", - "yAxisValue" : 187 - }, - { - "xAxisValue" : "2021-09-08T00:00:00.000Z", - "yAxisValue" : 161 - }, - { - "xAxisValue" : "2021-09-09T00:00:00.000Z", - "yAxisValue" : 128 - }, - { - "xAxisValue" : "2021-09-10T00:00:00.000Z", - "yAxisValue" : 127 - }, - { - "xAxisValue" : "2021-09-11T00:00:00.000Z", - "yAxisValue" : 87 - }, - { - "xAxisValue" : "2021-09-12T00:00:00.000Z", - "yAxisValue" : 123 - }, - { - "xAxisValue" : "2021-09-13T00:00:00.000Z", - "yAxisValue" : 138 - }, - { - "xAxisValue" : "2021-09-14T00:00:00.000Z", - "yAxisValue" : 135 - }, - { - "xAxisValue" : "2021-09-15T00:00:00.000Z", - "yAxisValue" : 146 - }, - { - "xAxisValue" : "2021-09-16T00:00:00.000Z", - "yAxisValue" : 158 - }, - { - "xAxisValue" : "2021-09-17T00:00:00.000Z", - "yAxisValue" : 132 - }, - { - "xAxisValue" : "2021-09-18T00:00:00.000Z", - "yAxisValue" : 140 - }, - { - "xAxisValue" : "2021-09-19T00:00:00.000Z", - "yAxisValue" : 158 - }, - { - "xAxisValue" : "2021-09-20T00:00:00.000Z", - "yAxisValue" : 166 - }, - { - "xAxisValue" : "2021-09-21T00:00:00.000Z", - "yAxisValue" : 195 - }, - { - "xAxisValue" : "2021-09-22T00:00:00.000Z", - "yAxisValue" : 330 - }, - { - "xAxisValue" : "2021-09-23T00:00:00.000Z", - "yAxisValue" : 255 - }, - { - "xAxisValue" : "2021-09-24T00:00:00.000Z", - "yAxisValue" : 245 - }, - { - "xAxisValue" : "2021-09-25T00:00:00.000Z", - "yAxisValue" : 273 - }, - { - "xAxisValue" : "2021-09-26T00:00:00.000Z", - "yAxisValue" : 261 - }, - { - "xAxisValue" : "2021-09-27T00:00:00.000Z", - "yAxisValue" : 248 - }, - { - "xAxisValue" : "2021-09-28T00:00:00.000Z", - "yAxisValue" : 299 - }, - { - "xAxisValue" : "2021-09-29T00:00:00.000Z", - "yAxisValue" : 319 - }, - { - "xAxisValue" : "2021-09-30T00:00:00.000Z", - "yAxisValue" : 283 - }, - { - "xAxisValue" : "2021-10-01T00:00:00.000Z", - "yAxisValue" : 320 - }, - { - "xAxisValue" : "2021-10-02T00:00:00.000Z", - "yAxisValue" : 326 - }, - { - "xAxisValue" : "2021-10-03T00:00:00.000Z", - "yAxisValue" : 339 - }, - { - "xAxisValue" : "2021-10-04T00:00:00.000Z", - "yAxisValue" : 337 - }, - { - "xAxisValue" : "2021-10-05T00:00:00.000Z", - "yAxisValue" : 100 - } - ] -} -""", -""" -{ - "id" : "9ECA2C34-58B1-4532-B35D-8DC04C796778", - "calculationDuration" : 0.60822093486785889, - "insight" : { - "id" : "9ECA2C34-58B1-4532-B35D-8DC04C796778", - "accentColor" : "F38630", - "filters" : { +private let monthlyDates = [ + "2021-08-01T00:00:00.000Z", + "2021-09-01T00:00:00.000Z", + "2021-10-01T00:00:00.000Z", +] - }, - "groupID" : "D0DAB332-3C26-46BE-98EF-D828587292D0", - "uniqueUser" : false, - "breakdownKey" : "modelName", - "title" : "Device Type Breakdown", - "widgetable" : false, - "lastRunAt" : "2021-10-05T11:30:36Z", - "order" : 0, - "displayMode" : "pieChart", - "lastRunTime" : 0.60822093486785889, - "groupBy" : "day", - "isExpanded" : false - }, - "calculatedAt" : "2021-10-05T11:30:36Z", - "data" : [ - { - "xAxisValue" : "iPhone XR", - "yAxisValue" : 1060 - }, - { - "xAxisValue" : "iPhone 11", - "yAxisValue" : 877 - }, - { - "xAxisValue" : "iPhone 12 Pro Max", - "yAxisValue" : 764 - }, - { - "xAxisValue" : "iPhone SE 2nd Gen", - "yAxisValue" : 516 - }, - { - "xAxisValue" : "iPhone XS Max Global", - "yAxisValue" : 482 - }, - { - "xAxisValue" : "iPhone 11 Pro", - "yAxisValue" : 347 - }, - { - "xAxisValue" : "iPhone 11 Pro Max", - "yAxisValue" : 304 - }, - { - "xAxisValue" : "iPhone 12 Pro", - "yAxisValue" : 268 - }, - { - "xAxisValue" : "iPhone X GSM", - "yAxisValue" : 247 - }, - { - "xAxisValue" : "iPhone 12", - "yAxisValue" : 244 - }, - { - "xAxisValue" : "iPhone 8 Plus (10,5)", - "yAxisValue" : 233 - }, - { - "xAxisValue" : "iPhone X Global", - "yAxisValue" : 185 - }, - { - "xAxisValue" : "iPhone XS", - "yAxisValue" : 181 - }, - { - "xAxisValue" : "iPhone SE (GSM)", - "yAxisValue" : 166 - }, - { - "xAxisValue" : "iPhone 8 (10,4)", - "yAxisValue" : 146 - }, - { - "xAxisValue" : "iPhone 7 (9,3)", - "yAxisValue" : 143 - }, - { - "xAxisValue" : "iPhone 12 Mini", - "yAxisValue" : 142 - }, - { - "xAxisValue" : "iPhone 7 Plus (9,4)", - "yAxisValue" : 132 - }, - { - "xAxisValue" : "iPhone 8", - "yAxisValue" : 95 - }, - { - "xAxisValue" : "iPhone14,3", - "yAxisValue" : 83 - }, - { - "xAxisValue" : "iPhone 7", - "yAxisValue" : 76 - }, - { - "xAxisValue" : "iPhone 7 Plus", - "yAxisValue" : 54 - }, - { - "xAxisValue" : "iPhone 6s", - "yAxisValue" : 35 - }, - { - "xAxisValue" : "iPhone14,5", - "yAxisValue" : 34 - }, - { - "xAxisValue" : "iPhone14,2", - "yAxisValue" : 30 - }, - { - "xAxisValue" : "iPhone 8 Plus", - "yAxisValue" : 19 - }, - { - "xAxisValue" : "iPad Pro 12.9 inch 4th Gen (WiFi+Cellular)", - "yAxisValue" : 7 - }, - { - "xAxisValue" : "iPad mini 5th Gen (WiFi)", - "yAxisValue" : 5 - }, - { - "xAxisValue" : "iPad air 4th Gen (WiFi)", - "yAxisValue" : 4 - }, - { - "xAxisValue" : "iPad Air 2 (WiFi)", - "yAxisValue" : 1 - }, - { - "xAxisValue" : "iPhone14,4", - "yAxisValue" : 1 - } - ] -} -""", -""" -{ - "id" : "6106D79C-215C-4EF7-9F10-BF9DF6344C1C", - "calculationDuration" : 0.60810494422912598, - "insight" : { - "id" : "6106D79C-215C-4EF7-9F10-BF9DF6344C1C", - "accentColor" : "EB2727", - "filters" : { +private let dailyDates = [ + "2021-08-31T00:00:00.000Z", + "2021-09-01T00:00:00.000Z", + "2021-09-02T00:00:00.000Z", + "2021-09-03T00:00:00.000Z", + "2021-09-04T00:00:00.000Z", + "2021-09-05T00:00:00.000Z", + "2021-09-06T00:00:00.000Z", + "2021-09-07T00:00:00.000Z", + "2021-09-08T00:00:00.000Z", + "2021-09-09T00:00:00.000Z", + "2021-09-10T00:00:00.000Z", + "2021-09-11T00:00:00.000Z", + "2021-09-12T00:00:00.000Z", + "2021-09-13T00:00:00.000Z", + "2021-09-14T00:00:00.000Z", + "2021-09-15T00:00:00.000Z", + "2021-09-16T00:00:00.000Z", + "2021-09-17T00:00:00.000Z", + "2021-09-18T00:00:00.000Z", + "2021-09-19T00:00:00.000Z", + "2021-09-20T00:00:00.000Z", + "2021-09-21T00:00:00.000Z", + "2021-09-22T00:00:00.000Z", + "2021-09-23T00:00:00.000Z", + "2021-09-24T00:00:00.000Z", + "2021-09-25T00:00:00.000Z", + "2021-09-26T00:00:00.000Z", + "2021-09-27T00:00:00.000Z", + "2021-09-28T00:00:00.000Z", + "2021-09-29T00:00:00.000Z", + "2021-09-30T00:00:00.000Z", + "2021-10-01T00:00:00.000Z", + "2021-10-02T00:00:00.000Z", + "2021-10-03T00:00:00.000Z", + "2021-10-04T00:00:00.000Z", + "2021-10-05T00:00:00.000Z", +] - }, - "groupID" : "D0DAB332-3C26-46BE-98EF-D828587292D0", - "uniqueUser" : false, - "title" : "OS Breakdown", - "breakdownKey" : "systemVersion", - "widgetable" : true, - "lastRunAt" : "2021-10-05T11:30:36Z", - "groupBy" : "day", - "displayMode" : "pieChart", - "lastRunTime" : 0.60810494422912598, - "order" : 0, - "isExpanded" : false - }, - "calculatedAt" : "2021-10-05T11:30:36Z", - "data" : [ - { - "xAxisValue" : "iOS 14.7.1", - "yAxisValue" : 2774 - }, - { - "xAxisValue" : "iOS 15.0", - "yAxisValue" : 2769 - }, - { - "xAxisValue" : "iOS 14.8", - "yAxisValue" : 394 - }, - { - "xAxisValue" : "iOS 15.0.1", - "yAxisValue" : 335 - }, - { - "xAxisValue" : "iOS 14.6", - "yAxisValue" : 319 - }, - { - "xAxisValue" : "iOS 15.1", - "yAxisValue" : 157 - }, - { - "xAxisValue" : "iOS 14.7", - "yAxisValue" : 39 - }, - { - "xAxisValue" : "iOS 14.2", - "yAxisValue" : 22 - }, - { - "xAxisValue" : "iOS 14.4.2", - "yAxisValue" : 21 - }, - { - "xAxisValue" : "iOS 14.3", - "yAxisValue" : 15 - }, - { - "xAxisValue" : "iOS 14.0", - "yAxisValue" : 12 - }, - { - "xAxisValue" : "iOS 14.4", - "yAxisValue" : 12 - }, - { - "xAxisValue" : "iOS 14.5.1", - "yAxisValue" : 6 - }, - { - "xAxisValue" : "iOS 13.5.1", - "yAxisValue" : 3 - }, - { - "xAxisValue" : "iOS 14.2.1", - "yAxisValue" : 2 - }, - { - "xAxisValue" : "iOS 13.3.1", - "yAxisValue" : 1 - } - ] -} -""", -""" -{ - "id" : "0EFDB5F0-446D-4468-95CB-2D5CD75AF8C8", - "calculationDuration" : 0.6224219799041748, - "insight" : { - "id" : "0EFDB5F0-446D-4468-95CB-2D5CD75AF8C8", - "accentColor" : "E0E4CC", - "filters" : { - "platform" : "iOS" - }, - "groupID" : "D0DAB332-3C26-46BE-98EF-D828587292D0", - "uniqueUser" : true, - "title" : "Daily Active Users", - "widgetable" : true, - "lastRunAt" : "2021-10-05T11:30:36Z", - "order" : 1, - "displayMode" : "barChart", - "groupBy" : "day", - "lastRunTime" : 0.6224219799041748, - "isExpanded" : true - }, - "calculatedAt" : "2021-10-05T11:30:36Z", - "data" : [ - { - "xAxisValue" : "2021-08-31T00:00:00.000Z", - "yAxisValue" : 37 - }, - { - "xAxisValue" : "2021-09-01T00:00:00.000Z", - "yAxisValue" : 42 - }, - { - "xAxisValue" : "2021-09-02T00:00:00.000Z", - "yAxisValue" : 33 - }, - { - "xAxisValue" : "2021-09-03T00:00:00.000Z", - "yAxisValue" : 32 - }, - { - "xAxisValue" : "2021-09-04T00:00:00.000Z", - "yAxisValue" : 36 - }, - { - "xAxisValue" : "2021-09-05T00:00:00.000Z", - "yAxisValue" : 39 - }, - { - "xAxisValue" : "2021-09-06T00:00:00.000Z", - "yAxisValue" : 36 - }, - { - "xAxisValue" : "2021-09-07T00:00:00.000Z", - "yAxisValue" : 51 - }, - { - "xAxisValue" : "2021-09-08T00:00:00.000Z", - "yAxisValue" : 38 - }, - { - "xAxisValue" : "2021-09-09T00:00:00.000Z", - "yAxisValue" : 37 - }, - { - "xAxisValue" : "2021-09-10T00:00:00.000Z", - "yAxisValue" : 37 - }, - { - "xAxisValue" : "2021-09-11T00:00:00.000Z", - "yAxisValue" : 26 - }, - { - "xAxisValue" : "2021-09-12T00:00:00.000Z", - "yAxisValue" : 35 - }, - { - "xAxisValue" : "2021-09-13T00:00:00.000Z", - "yAxisValue" : 40 - }, - { - "xAxisValue" : "2021-09-14T00:00:00.000Z", - "yAxisValue" : 30 - }, - { - "xAxisValue" : "2021-09-15T00:00:00.000Z", - "yAxisValue" : 37 - }, - { - "xAxisValue" : "2021-09-16T00:00:00.000Z", - "yAxisValue" : 46 - }, - { - "xAxisValue" : "2021-09-17T00:00:00.000Z", - "yAxisValue" : 33 - }, - { - "xAxisValue" : "2021-09-18T00:00:00.000Z", - "yAxisValue" : 41 - }, - { - "xAxisValue" : "2021-09-19T00:00:00.000Z", - "yAxisValue" : 33 - }, - { - "xAxisValue" : "2021-09-20T00:00:00.000Z", - "yAxisValue" : 42 - }, - { - "xAxisValue" : "2021-09-21T00:00:00.000Z", - "yAxisValue" : 50 - }, - { - "xAxisValue" : "2021-09-22T00:00:00.000Z", - "yAxisValue" : 55 - }, - { - "xAxisValue" : "2021-09-23T00:00:00.000Z", - "yAxisValue" : 60 - }, - { - "xAxisValue" : "2021-09-24T00:00:00.000Z", - "yAxisValue" : 46 - }, - { - "xAxisValue" : "2021-09-25T00:00:00.000Z", - "yAxisValue" : 67 - }, - { - "xAxisValue" : "2021-09-26T00:00:00.000Z", - "yAxisValue" : 61 - }, - { - "xAxisValue" : "2021-09-27T00:00:00.000Z", - "yAxisValue" : 63 - }, - { - "xAxisValue" : "2021-09-28T00:00:00.000Z", - "yAxisValue" : 61 - }, - { - "xAxisValue" : "2021-09-29T00:00:00.000Z", - "yAxisValue" : 69 - }, - { - "xAxisValue" : "2021-09-30T00:00:00.000Z", - "yAxisValue" : 61 - }, - { - "xAxisValue" : "2021-10-01T00:00:00.000Z", - "yAxisValue" : 71 - }, - { - "xAxisValue" : "2021-10-02T00:00:00.000Z", - "yAxisValue" : 66 - }, - { - "xAxisValue" : "2021-10-03T00:00:00.000Z", - "yAxisValue" : 73 - }, - { - "xAxisValue" : "2021-10-04T00:00:00.000Z", - "yAxisValue" : 70 - }, - { - "xAxisValue" : "2021-10-05T00:00:00.000Z", - "yAxisValue" : 40 - } - ] -} -""" +private let breakdownKeyValues = [ + "iPhone XR", + "iPhone 11", + "iPhone 12 Pro Max", + "iPhone SE 2nd Gen", + "iPhone XS Max Global", + "iPhone 11 Pro", + "iPhone 11 Pro Max", +] + +let insightCalculationResults = [ + DTOv2.InsightCalculationResult( + id: UUID(uuidString: "36ECF853-7651-40C1-BABF-6ED06324C16A")!, + insight: DTOv2.Insight( + id: UUID(uuidString: "36ECF853-7651-40C1-BABF-6ED06324C16A")!, + groupID: UUID(uuidString: "D0DAB332-3C26-46BE-98EF-D828587292D0")!, + order: 0, + title: "Active Users by Month", + type: .timeseries, + accentColor: nil, + customQuery: nil, + signalType: nil, + uniqueUser: true, + filters: [:], + breakdownKey: nil, + groupBy: .month, + displayMode: .raw, + isExpanded: false, + lastRunTime: 0.47125601768493652, + lastRunAt: Date(timeIntervalSince1970: 1_633_425_036) + ), + data: generateResultData(type: .timeseries, granularity: .month), + calculatedAt: Date(), + calculationDuration: 0.47125601768493652 + ), + + DTOv2.InsightCalculationResult( + id: UUID(uuidString: "C8DB1A2A-40DE-40F8-A4DD-741F3D97F9F3")!, + insight: DTOv2.Insight( + id: UUID(uuidString: "C8DB1A2A-40DE-40F8-A4DD-741F3D97F9F3")!, + groupID: UUID(uuidString: "D0DAB332-3C26-46BE-98EF-D828587292D0")!, + order: 0, + title: "Signals by Day", + type: .timeseries, + accentColor: "C2CBCE", + customQuery: nil, + signalType: nil, + uniqueUser: true, + filters: [:], + breakdownKey: nil, + groupBy: .day, + displayMode: .lineChart, + isExpanded: false, + lastRunTime: 0.52053999900817871, + lastRunAt: Date(timeIntervalSince1970: 1_633_425_036) + ), + data: generateResultData(type: .timeseries, granularity: .day), + calculatedAt: Date(), + calculationDuration: 0.52053999900817871 + ), + + DTOv2.InsightCalculationResult( + id: UUID(uuidString: "025B8420-E688-4826-B3A7-8F5497C277EE")!, + insight: DTOv2.Insight( + id: UUID(uuidString: "025B8420-E688-4826-B3A7-8F5497C277EE")!, + groupID: UUID(uuidString: "D0DAB332-3C26-46BE-98EF-D828587292D0")!, + order: 0, + title: "Custom Query Insight", + type: .customQuery, + accentColor: "E0A4C3", + customQuery: nil, + signalType: nil, + uniqueUser: false, + filters: [:], + breakdownKey: nil, + groupBy: .day, + displayMode: .barChart, + isExpanded: false, + lastRunTime: 0.52057492733001709, + lastRunAt: Date(timeIntervalSince1970: 1_633_425_036) + ), + data: generateResultData(type: .timeseries, granularity: .day), + calculatedAt: Date(), + calculationDuration: 0.52057492733001709 + ), + + DTOv2.InsightCalculationResult( + id: UUID(uuidString: "9ECA2C34-58B1-4532-B35D-8DC04C796778")!, + insight: DTOv2.Insight( + id: UUID(uuidString: "9ECA2C34-58B1-4532-B35D-8DC04C796778")!, + groupID: UUID(uuidString: "D0DAB332-3C26-46BE-98EF-D828587292D0")!, + order: 0, + title: "Device Type Breakdown", + type: .topN, + accentColor: "F38630", + customQuery: nil, + signalType: nil, + uniqueUser: false, + filters: [:], + breakdownKey: "modelName", + groupBy: nil, + displayMode: .pieChart, + isExpanded: false, + lastRunTime: 0.60822093486785889, + lastRunAt: Date(timeIntervalSince1970: 1_633_425_036) + ), + data: generateResultData(type: .topN, granularity: .all), + calculatedAt: Date(), + calculationDuration: 0.60822093486785889 + ), + + DTOv2.InsightCalculationResult( + id: UUID(uuidString: "6106D79C-215C-4EF7-9F10-BF9DF6344C1C")!, + insight: DTOv2.Insight( + id: UUID(uuidString: "6106D79C-215C-4EF7-9F10-BF9DF6344C1C")!, + groupID: UUID(uuidString: "D0DAB332-3C26-46BE-98EF-D828587292D0")!, + order: 0, + title: "OS Breakdown", + type: .topN, + accentColor: "EB2727", + customQuery: nil, + signalType: nil, + uniqueUser: false, + filters: ["platform": "iOS"], + breakdownKey: "systemVersion", + groupBy: nil, + displayMode: .pieChart, + isExpanded: false, + lastRunTime: 0.60810494422912598, + lastRunAt: Date(timeIntervalSince1970: 1_633_425_036) + ), + data: generateResultData(type: .topN, granularity: .all), + calculatedAt: Date(), + calculationDuration: 0.60810494422912598 + ), + + DTOv2.InsightCalculationResult( + id: UUID(uuidString: "0EFDB5F0-446D-4468-95CB-2D5CD75AF8C8")!, + insight: DTOv2.Insight( + id: UUID(uuidString: "0EFDB5F0-446D-4468-95CB-2D5CD75AF8C8")!, + groupID: UUID(uuidString: "D0DAB332-3C26-46BE-98EF-D828587292D0")!, + order: 1, + title: "Daily Active Users", + type: .timeseries, + accentColor: "E0E4CC", + customQuery: nil, + signalType: nil, + uniqueUser: true, + filters: ["platform": "iOS"], + breakdownKey: nil, + groupBy: .day, + displayMode: .barChart, + isExpanded: true, + lastRunTime: 0.6224219799041748, + lastRunAt: Date(timeIntervalSince1970: 1_633_425_036) + ), + data: generateResultData(type: .timeseries, granularity: .day), + calculatedAt: Date(), + calculationDuration: 0.6224219799041748 + ), ] - .map { - $0.data(using: .utf8)! - } - .map { - try! JSONDecoder.telemetryDecoder.decode(DTOv2.InsightCalculationResult.self, from: $0) - }