modernize join
This commit is contained in:
parent
31f6c6d61e
commit
9752f27afb
1 changed files with 16 additions and 42 deletions
|
@ -134,48 +134,22 @@ produceProductOverviews
|
||||||
)
|
)
|
||||||
produceProductOverviews refine =
|
produceProductOverviews refine =
|
||||||
proc () -> do
|
proc () -> do
|
||||||
(p, i2, i6, i6a, i7, i8, i9, i11, i12, i13, a3, a4)
|
(p, i2, i6, i6a, i7, i8, i9, i11, i12, i13) <-
|
||||||
<- orderBy (asc (\(_, a2, _, _, _, _, _, _, _, _, _, _) -> a2)) (leftJoinF
|
selectTable productTable -< ()
|
||||||
(\(pid, pi2, pi6, pi6a, pi7, pi8, pi9, pi11, pi12, pi13)
|
(_, _, a3, a4, _) <- do
|
||||||
(_, _, ai3, ai4, _) ->
|
(a1, a2, a3, a4, a5) <- selectTable amountTable -< ()
|
||||||
(pid, pi2, pi6, pi6a, pi7, pi8, pi9, pi11, pi12, pi13, ai3, ai4)
|
(b1, b2) <- do
|
||||||
)
|
(ib1, ib2, _, _, _) <- selectTable amountTable -< ()
|
||||||
(const
|
(laterally . aggregate)
|
||||||
( toFields (0 :: Int) :: Column SqlInt4
|
(
|
||||||
, toFields ("ERROR PRODUCT" :: T.Text) :: Column SqlText
|
(,)
|
||||||
, toFields (0 :: Int) :: Column SqlInt4
|
<$> P.lmap fst O.groupBy
|
||||||
, toFields (Just (0 :: Int)) :: Column (Nullable SqlInt4)
|
<*> P.lmap snd O.max
|
||||||
, toFields (Just (0 :: Int)) :: Column (Nullable SqlInt4)
|
)
|
||||||
, toFields (0 :: Int) :: Column SqlInt4
|
(arr (\(ib1, ib2, _, _, _) -> (ib1, ib2)) <<< selectTable amountTable ) -< ()
|
||||||
, toFields (0 :: Int) :: Column SqlInt4
|
returnA -< (ib1, ib2)
|
||||||
, toFields (0 :: Int) :: Column SqlInt4
|
restrict -< a1 .== b1 .&& a2 .== b2
|
||||||
, toFields (Just (0 :: Int)) :: Column (Nullable SqlInt4)
|
returnA -< (b1, b2, a3, a4, a5)
|
||||||
, toFields (Just ("" :: T.Text)) :: Column (Nullable SqlText)
|
|
||||||
, toFields (0 :: Int) :: Column SqlInt4
|
|
||||||
, toFields (0 :: Int) :: Column SqlInt4
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(\(pid, _, _, _, _, _, _, _, _, _)
|
|
||||||
(aid, _, _, _, _) ->
|
|
||||||
pid .== aid
|
|
||||||
)
|
|
||||||
(selectTable productTable)
|
|
||||||
(joinF
|
|
||||||
(\(_, _, a3, a4, a5) (b1, b2) ->
|
|
||||||
(b1, b2, a3, a4, a5)
|
|
||||||
)
|
|
||||||
(\(a1, a2, _, _, _) (b1, b2) ->
|
|
||||||
(a1 .== b1) .&& (a2 .== b2)
|
|
||||||
)
|
|
||||||
(selectTable amountTable)
|
|
||||||
(aggregate
|
|
||||||
((,)
|
|
||||||
<$> P.lmap fst O.groupBy
|
|
||||||
<*> P.lmap snd O.max
|
|
||||||
)
|
|
||||||
(arr (\(a, b, _, _, _) -> (a, b)) <<< selectTable amountTable))
|
|
||||||
)) -< ()
|
|
||||||
-- <<< arr (\_ -> (selectTable productTable, selectTable amountTable)) -< ()
|
|
||||||
restrict -< case refine of
|
restrict -< case refine of
|
||||||
AllProducts -> toFields True
|
AllProducts -> toFields True
|
||||||
AvailableProducts -> a3 ./= (toFields (0 :: Int) :: Column SqlInt4)
|
AvailableProducts -> a3 ./= (toFields (0 :: Int) :: Column SqlInt4)
|
||||||
|
|
Loading…
Reference in a new issue