flowmachine.core.subscriber_subsetter¶
Class SubscriberSubsetterBase¶
SubscriberSubsetterBase()
Base class for the different types of subscriber subsets.
Attributes¶
Methods¶
apply_subset_if_needed¶
apply_subset_if_needed(self, sql, *, subscriber_identifier)
is_proper_subset¶
is_proper_subset
query_id¶
query_id
Class SubscriberSubsetterForAllSubscribers¶
SubscriberSubsetterForAllSubscribers()
Represents the subset of all subscribers - i.e., no subsetting at all. In other words this is the "null object" for the subsetting logic, which represents the case of "no work needed". The reason this exists is so that external code does not need to know anything about the subsetting logic or implementation and can use any of these classes completely interchangeably, no matter what kind of subset is required or whether any subsetting is needed at all. If we didn't have this class then external code would need to make a case distinction to check if subsetting is needed, which leads to coupling between unrelated parts of the code base, unnecessary complexity and makes testing of all possible cases much difficult.
Attributes¶
Methods¶
apply_subset_if_needed¶
apply_subset_if_needed(self, sql, *, subscriber_identifier=None)
Return the input query unchanged, since no subsetting is applied.
Parameters¶
-
sql
:sqlalchemy.sql.ClauseElement
The SQL query to which the subset should be applied.
-
subscriber_identifier
:str
This argument is ignored for subsets of type 'AllSubscribers'.
query_id¶
query_id
Class SubscriberSubsetterForExplicitSubset¶
SubscriberSubsetterForExplicitSubset(subscribers)
Represents a subset given by an explicit list of subscribers.
Attributes¶
Methods¶
apply_subset_if_needed¶
apply_subset_if_needed(self, sql, *, subscriber_identifier)
Return a modified version of the input SQL query which has the subset applied.
Parameters¶
-
sql
:sqlalchemy.sql.ClauseElement
The SQL query to which the subset should be applied.
-
subscriber_identifier
:str
The column in the parent table which contains the subscriber information.
Returns¶
sqlalchemy.sql.ClauseElement
query_id¶
query_id
Class SubscriberSubsetterForFlowmachineQuery¶
SubscriberSubsetterForFlowmachineQuery(flowmachine_query)
Represents a subset given by a flowmachine query.
Attributes¶
Methods¶
apply_subset_if_needed¶
apply_subset_if_needed(self, sql, *, subscriber_identifier=None)
Return a modified version of the input SQL query which has the subset applied.
Parameters¶
-
sql
:sqlalchemy.sql.ClauseElement
The SQL query to which the subset should be applied.
-
subscriber_identifier
:str
This argument is ignored for subsets of type 'SubscriberSubsetterForFlowmachineQuery'.
Returns¶
sqlalchemy.sql.ClauseElement
query_id¶
query_id
make_subscriber_subsetter¶
make_subscriber_subsetter(subset)
Return an appropriate subsetter for the given input.
Parameters¶
-
subset
:SubscriberSubsetterBase
,flowmachine.Query
,tuple
,list
,None
,"all"
This can be one of the following: - "all" or None: represents the subset of "all subscribers (i.e., no subsetting at all) - list or tuple: represents a subset of an explicit list of subscribers - flowmachine.Query: represents a subset given by the result of a flowmachine query (where the resulting table must have a "subscriber" column) If
subset
is already an instance of SubscriberSubsetterBase then it is returned unchanged.