Skip to content

Commit

Permalink
multitenant: fix cloud schema files
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 99f04df
  • Loading branch information
ecthiender authored and hasura-bot committed Feb 22, 2021
1 parent 4fa34e1 commit cad013c
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions server/src-lib/Hasura/Eventing/ScheduledTrigger.hs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ module Hasura.Eventing.ScheduledTrigger
, withCount
, invocationFieldExtractors
, mkEventIdBoolExp
, EventTables (..)
) where

import Hasura.Prelude
Expand Down Expand Up @@ -813,20 +814,28 @@ getInvocationsTx
-> ScheduledEventPagination
-> Q.TxE QErr (WithTotalCount [ScheduledEventInvocation])
getInvocationsTx invocationsBy pagination = do
let sql = Q.fromBuilder $ toSQL $ getInvocationsQuery invocationsBy pagination
let eventsTables = EventTables oneOffInvocationsTable cronInvocationsTable cronEventsTable
sql = Q.fromBuilder $ toSQL $ getInvocationsQuery eventsTables invocationsBy pagination
(withCount . Q.getRow) <$> Q.withQE defaultTxErrorHandler sql () True
where
oneOffInvocationsTable = QualifiedObject "hdb_catalog" $ TableName "hdb_scheduled_event_invocation_logs"
cronInvocationsTable = QualifiedObject "hdb_catalog" $ TableName "hdb_cron_event_invocation_logs"

data EventTables
= EventTables
{ etOneOffInvocationsTable :: QualifiedTable
, etCronInvocationsTable :: QualifiedTable
, etCronEventsTable :: QualifiedTable
}

getInvocationsQuery :: GetInvocationsBy -> ScheduledEventPagination -> S.Select
getInvocationsQuery invocationsBy pagination =
getInvocationsQuery :: EventTables -> GetInvocationsBy -> ScheduledEventPagination -> S.Select
getInvocationsQuery (EventTables oneOffInvocationsTable cronInvocationsTable cronEventsTable') invocationsBy pagination =
mkPaginationSelectExp allRowsSelect pagination
where
createdAtOrderBy table =
let createdAtCol = S.SEQIdentifier $ S.mkQIdentifierTable table $ Identifier "created_at"
in S.OrderByExp $ flip (NE.:|) [] $ S.OrderByItem createdAtCol (Just S.OTDesc) Nothing

oneOffInvocationsTable = QualifiedObject "hdb_catalog" $ TableName "hdb_scheduled_event_invocation_logs"
cronInvocationsTable = QualifiedObject "hdb_catalog" $ TableName "hdb_cron_event_invocation_logs"

allRowsSelect = case invocationsBy of
GIBEventId eventId eventType ->
let table = case eventType of
Expand All @@ -849,7 +858,7 @@ getInvocationsQuery invocationsBy pagination =
}
SECron triggerName ->
let invocationTable = cronInvocationsTable
eventTable = cronEventsTable
eventTable = cronEventsTable'
joinCondition = S.JoinOn $ S.BECompare S.SEQ
(S.SEQIdentifier $ S.mkQIdentifierTable eventTable $ Identifier "id")
(S.SEQIdentifier $ S.mkQIdentifierTable invocationTable $ Identifier "event_id")
Expand Down

0 comments on commit cad013c

Please sign in to comment.