Skip to content

Commit

Permalink
Merge pull request #291 from amihaiemil/287
Browse files Browse the repository at this point in the history
#287 pass the list to the supplier
  • Loading branch information
amihaiemil authored Apr 14, 2021
2 parents 936066a + af0b345 commit e4630b7
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions src/main/java/com/selfxdsd/storage/SelfInvoicedTasks.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,28 +75,24 @@ public SelfInvoicedTasks(
* InvoicedTasks of an Invoice.
* @param invoice Invoice.
* @return InvoicedTasks of the specified Invoice.
* @todo #280:60min Initialize the Stream from a List, to avoid querying
* the DB at every Stream.get().
*/
@Override
public InvoicedTasks ofInvoice(final Invoice invoice) {
final Result<Record> results = database.jooq()
.select()
.from(SLF_INVOICEDTASKS_XDSD)
.where(
SLF_INVOICEDTASKS_XDSD.INVOICEID.eq(
invoice.invoiceId()
)
).fetch();
final List<InvoicedTask> tasks = new ArrayList<>();
for (final Record rec : results) {
tasks.add(invoicedTaskFromRecord(rec, invoice));
}
return new InvoiceTasks(
invoice,
() -> {
final Result<Record> results = database.jooq()
.select()
.from(SLF_INVOICEDTASKS_XDSD)
.where(
SLF_INVOICEDTASKS_XDSD.INVOICEID.eq(
invoice.invoiceId()
)
).fetch();
final List<InvoicedTask> tasks = new ArrayList<>();
for (final Record rec : results) {
tasks.add(invoicedTaskFromRecord(rec, invoice));
}
return tasks.stream();
},
() -> tasks.stream(),
this.storage
);
}
Expand Down

0 comments on commit e4630b7

Please sign in to comment.