Skip to content

Commit

Permalink
#287 pass the list to the supplier
Browse files Browse the repository at this point in the history
  • Loading branch information
amihaiemil committed Apr 14, 2021
1 parent 936066a commit af0b345
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

1 comment on commit af0b345

@zoeself
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amihaiemil I've closed the Issues [#287] since their to-dos disappeared from the code.

The to-dos may have been removed in an earlier commit, but I've found it just now.

Please sign in to comment.