Skip to content

Commit

Permalink
remove sip enriched view
Browse files Browse the repository at this point in the history
  • Loading branch information
praslnx8 committed Jul 1, 2024
1 parent 93d70ee commit 8a8c645
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 302 deletions.
6 changes: 3 additions & 3 deletions lib/api/apis/sip_api_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ class SipApiImpl implements SipApi {

@override
Future<List<SipDO>> getAll() async {
return (_db.select(_db.sipEnrichedView)
return (_db.select(_db.sipTable)
..orderBy([(t) => OrderingTerm.desc(t.startDate)]))
.get();
}

@override
Future<List<SipDO>> getBy({final int? investmentId}) async {
if (investmentId != null) {
return (_db.select(_db.sipEnrichedView)
return (_db.select(_db.sipTable)
..where((t) => t.investmentId.equals(investmentId))
..orderBy([(t) => OrderingTerm.desc(t.startDate)]))
.get();
Expand All @@ -47,7 +47,7 @@ class SipApiImpl implements SipApi {

@override
Future<SipDO> getById({required final int id}) async {
return (_db.select(_db.sipEnrichedView)..where((t) => t.id.equals(id)))
return (_db.select(_db.sipTable)..where((t) => t.id.equals(id)))
.getSingle();
}

Expand Down
35 changes: 1 addition & 34 deletions lib/api/db/app_database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class TransactionTable extends Table {
DateTimeColumn get createdOn => dateTime().named('CREATED_ON')();
}

@DataClassName('BaseSipDO')
@DataClassName('SipDO')
class SipTable extends Table {
IntColumn get id => integer().named('ID').autoIncrement()();

Expand Down Expand Up @@ -206,38 +206,6 @@ abstract class InvestmentEnrichedView extends View {
..groupBy([investment.id]);
}

@DataClassName('SipDO')
abstract class SipEnrichedView extends View {
SipTable get sip;

InvestmentTable get investment;

TransactionTable get transaction;

Expression<String> get investmentName => investment.name;

Expression<int> get transactionCount => transaction.id
.count(distinct: true, filter: transaction.sipId.equalsExp(sip.id));

@override
Query as() => select([
sip.id,
sip.description,
sip.investmentId,
sip.amount,
sip.startDate,
sip.endDate,
sip.frequency,
sip.executedTill,
investmentName,
transactionCount,
]).from(sip).join([
innerJoin(investment, investment.id.equalsExp(sip.investmentId)),
leftOuterJoin(transaction, transaction.sipId.equalsExp(sip.id)),
])
..groupBy([sip.id]);
}

@DataClassName('GoalInvestmentDO')
abstract class GoalInvestmentEnrichedView extends View {
GoalInvestmentTable get goalInvestment;
Expand Down Expand Up @@ -320,7 +288,6 @@ class ExpenseTable extends Table {
], views: [
InvestmentEnrichedView,
GoalInvestmentEnrichedView,
SipEnrichedView,
GoalEnrichedView
])
class AppDatabase extends _$AppDatabase {
Expand Down
Loading

0 comments on commit 8a8c645

Please sign in to comment.