module analytics.data; import std.datetime; import handy_http_primitives : Optional; import asdf : serdeTransformOut; import util.money; import util.data; import account.model; /** * A common time-series data point. */ struct TimeSeriesPoint { /// The millisecond UTC timestamp. ulong x; /// The value at this timestamp. long y; } struct JournalEntryStub { SysTime timestamp; ulong accountId; AccountType accountType; ulong amount; AccountJournalEntryType type; } struct BalanceRecordStub { SysTime timestamp; ulong accountId; long value; } struct CategorySpendData { ulong categoryId; string categoryName; string categoryColor; @serdeTransformOut!serializeOptional Optional!ulong parentCategoryId; long amount; } /** * Repository that provides various functions for fetching data that's used in * the calculation of analytics, separate from usual app functionality. */ interface AnalyticsRepository { JournalEntryStub[] getJournalEntries( in Currency currency, in TimeRange timeRange ); BalanceRecordStub[] getBalanceRecords( in Currency currency, in TimeRange timeRange ); CategorySpendData[] getCategorySpendData( in Currency currency, in TimeRange timeRange ); }