Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*,
table: str = "all",
spatial_unit: AnySpatialUnit = make_spatial_unit("cell"),
direction: Union[Direction, str] = Direction.BOTH,
hours="all",
subscriber_subset=None,
subscriber_identifier="msisdn",
):
self.start = standardise_date(start)
self.stop = standardise_date(stop)
self.table = table
self.spatial_unit = spatial_unit
self.direction = Direction(direction)
self.unioned_query = location_joined_query(
EventsTablesUnion(
self.start,
self.stop,
columns=[
"id",
"outgoing",
"location_id",
"datetime",
subscriber_identifier,
],
tables=self.table,
hours=hours,
subscriber_subset=subscriber_subset,
subscriber_identifier=subscriber_identifier,
),
spatial_unit=self.spatial_unit,
time_col="datetime",
"minute",
"month",
"quarter",
"second",
"week",
"year",
)
if phase not in allowed_phases:
raise ValueError(
f"{phase} is not a valid phase. Choose one of {allowed_phases}"
)
self.phase = phase
self.unioned_query = EventsTablesUnion(
self.start,
self.stop,
tables=self.tables,
columns=column_list,
hours=hours,
subscriber_identifier=subscriber_identifier,
subscriber_subset=subscriber_subset,
)
super().__init__()
subscriber_identifier="msisdn",
direction: Union[str, Direction] = Direction.BOTH,
hours="all",
subscriber_subset=None,
tables="all",
):
self.start = standardise_date(start)
self.stop = standardise_date(stop)
self.subscriber_identifier = subscriber_identifier
self.direction = Direction(direction)
self.hours = hours
self.tables = tables
column_list = [self.subscriber_identifier, *self.direction.required_columns]
self.unioned_query = EventsTablesUnion(
self.start,
self.stop,
tables=self.tables,
columns=column_list,
hours=hours,
subscriber_identifier=subscriber_identifier,
subscriber_subset=subscriber_subset,
)
super().__init__()
self.time_cols = ["(datetime::date)::text AS date"]
if self.interval == "hour" or self.interval == "min":
self.time_cols.append("extract(hour FROM datetime) AS hour")
if self.interval == "min":
self.time_cols.append("extract(minute FROM datetime) AS min")
events_tables_union_cols = ["location_id", "datetime", subscriber_identifier]
# if we need to filter on outgoing/incoming calls, we will also fetch this
# column. Don't fetch it if it is not needed for both efficiency and the
# possibility that we might want to do pass another data type which does not
# have this information.
events_tables_union_cols += self.direction.required_columns
self.unioned = location_joined_query(
EventsTablesUnion(
self.start,
self.stop,
tables=self.table,
columns=events_tables_union_cols,
hours=hours,
subscriber_subset=subscriber_subset,
subscriber_identifier=subscriber_identifier,
),
spatial_unit=self.spatial_unit,
time_col="datetime",
)
super().__init__()
if self.statistic not in valid_stats:
raise ValueError(
"{} is not a valid statistic. Use one of {}".format(
self.statistic, valid_stats
)
)
column_list = [
self.subscriber_identifier,
"location_id",
"datetime",
*self.direction.required_columns,
]
self.unioned_query = location_joined_query(
EventsTablesUnion(
self.start,
self.stop,
tables=self.tables,
columns=column_list,
hours=hours,
subscriber_identifier=subscriber_identifier,
subscriber_subset=subscriber_subset,
),
spatial_unit=self.spatial_unit,
time_col="datetime",
)
super().__init__()
tables="all",
):
self.start = standardise_date(start)
self.stop = standardise_date(stop)
self.subscriber_identifier = subscriber_identifier
self.direction = Direction(direction)
self.hours = hours
self.tables = tables
column_list = [
self.subscriber_identifier,
"datetime",
*self.direction.required_columns,
]
self.unioned_query = EventsTablesUnion(
self.start,
self.stop,
tables=self.tables,
columns=column_list,
hours="all",
subscriber_identifier=subscriber_identifier,
subscriber_subset=subscriber_subset,
)
super().__init__()
):
self.start = standardise_date(start)
self.stop = standardise_date(stop)
self.hours = hours
self.direction = Direction(direction)
self.subscriber_identifier = subscriber_identifier
self.exclude_self_calls = exclude_self_calls
self.tables = tables
column_list = [
self.subscriber_identifier,
"msisdn_counterpart",
*self.direction.required_columns,
]
self.unioned_query = EventsTablesUnion(
self.start,
self.stop,
hours=self.hours,
tables=self.tables,
columns=column_list,
subscriber_identifier=self.subscriber_identifier,
subscriber_subset=subscriber_subset,
)
self._cols = ["subscriber", "degree"]
super().__init__()
raise ValueError(
"{} is not a valid statistic. Use one of {}".format(
self.statistic, valid_stats
)
)
column_list = [
self.subscriber_identifier,
"msisdn_counterpart",
"duration",
"location_id",
"datetime",
*self.direction.required_columns,
]
self.unioned_query = location_joined_query(
EventsTablesUnion(
self.start,
self.stop,
tables="events.calls",
columns=column_list,
hours=hours,
subscriber_subset=subscriber_subset,
subscriber_identifier=self.subscriber_identifier,
),
spatial_unit=self.spatial_unit,
time_col="datetime",
)
super().__init__()
self.statistic = statistic.lower()
if self.statistic not in valid_stats:
raise ValueError(
"{} is not a valid statistic. Use one of {}".format(
self.statistic, valid_stats
)
)
column_list = [
self.subscriber_identifier,
"outgoing",
"duration",
"msisdn_counterpart",
]
self.unioned_query = EventsTablesUnion(
self.start,
self.stop,
tables="events.calls",
columns=column_list,
hours=hours,
subscriber_subset=subscriber_subset,
subscriber_identifier=self.subscriber_identifier,
)
super().__init__()
self.tables = tables
self.start = standardise_date(start)
self.stop = standardise_date(stop)
self.hours = hours
self.direction = Direction(direction)
self.subscriber_identifier = subscriber_identifier
self.exclude_self_calls = exclude_self_calls
self.tables = tables
column_list = [
self.subscriber_identifier,
"msisdn_counterpart",
*self.direction.required_columns,
]
self.unioned_query = EventsTablesUnion(
self.start,
self.stop,
columns=column_list,
tables=self.tables,
subscriber_identifier=self.subscriber_identifier,
hours=hours,
subscriber_subset=subscriber_subset,
)
self._cols = ["subscriber", "msisdn_counterpart", "events", "proportion"]
super().__init__()