File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
internal/infrastructure/datasource/filesystem Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ func (o *orderRepository) Find(id order.ID) (order.Order, error) {
2828func (o * orderRepository ) Latest (optionAppliers ... options.Applier [order.ListerOption ]) iter.Seq2 [order.Order , error ] {
2929 option := options .Create (optionAppliers ... )
3030
31+ var canceledListBuffer []order.Order
32+
3133 return func (yield func (order.Order , error ) bool ) {
3234 for _ , o := range o .fs .data .orders {
3335 if option .Since != nil && o .CreatedAt ().Before (* option .Since ) {
@@ -37,12 +39,28 @@ func (o *orderRepository) Latest(optionAppliers ...options.Applier[order.ListerO
3739 continue
3840 }
3941 if option .IgnoreCheckedOut && o .Status == order .StatusCheckedOut {
40- break
42+ return
43+ }
44+ if o .Status == order .StatusCanceled {
45+ canceledListBuffer = append (canceledListBuffer , o )
46+ continue
4147 }
48+ for _ , o := range canceledListBuffer {
49+ if ! yield (o , nil ) {
50+ return
51+ }
52+ }
53+ canceledListBuffer = nil
54+ if ! yield (o , nil ) {
55+ return
56+ }
57+ }
58+ for _ , o := range canceledListBuffer {
4259 if ! yield (o , nil ) {
4360 return
4461 }
4562 }
63+ canceledListBuffer = nil
4664 }
4765}
4866
You can’t perform that action at this time.
0 commit comments