public static string AggregateUserActivity(UserActivityRaportData data) { var withTimestamps = data.Transactions.Select(t => new TransactionWithTimestamp { Timestamp = t.Timestamp.ToDateTime(), Transaction = t }); var accountsPortion = data.Accounts.SelectMany(a => AggregateUserAccountsTransactions(a, withTimestamps, data.Granularity)).ToArray(); var cardsTransactions = withTimestamps.Where(t => t.Transaction.CardId != null); var cardsPortion = data.Cards.SelectMany(c => AggregateUserCardTransactions(c, cardsTransactions, data.Granularity)).ToArray(); var paymentsTransactions = withTimestamps.Where(t => t.Transaction.PaymentId != null); var paymentsPortion = data.Payments.SelectMany(p => AggregateUserPaymentsTransactions(p, paymentsTransactions, data.Granularity)).ToArray(); var loansPortion = data.Loans.SelectMany(l => AggregateUserLoansTransactions(l, paymentsTransactions, data.Granularity)).ToArray(); return(ReportCsvSerializer.SerializerUserActivityReport(data, accountsPortion, cardsPortion, paymentsPortion, loansPortion)); }
public static string AggregateOverall(OverallReportData data) { var withTimestamps = data.Transactions.Select(t => new TransactionWithTimestamp { Timestamp = t.Timestamp.ToDateTime(), Transaction = t }); var periods = GroupByPeriods(data.Granularity, withTimestamps); var portions = new List <OverallReportPortion>(); foreach (var period in periods) { foreach (var aggregation in data.Aggregations) { var value = Aggregate(period, aggregation); portions.Add(new OverallReportPortion { Period = period.Key, Value = value, Aggregation = aggregation }); } } return(ReportCsvSerializer.SerializerOverallReport(data, portions.ToArray())); }