Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def create_hypertable_ops(table_name, hypertable_meta, is_existing=False):

# Create hypertable SQL
hypertable_sql = (
f"SELECT create_hypertable('{table_name}', by_range('{time_col}', INTERVAL '{chunk_interval}'));"
f"SELECT create_hypertable('{table_name}', by_range('{time_col}', INTERVAL '{chunk_interval}'),create_default_indexes => false);"
)

upgrade_ops.append(ops.ExecuteSQLOp(hypertable_sql))
Expand Down
2 changes: 1 addition & 1 deletion models/atlas_delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AtlasDelay(Base):
__tablename__ = 'ihr_atlas_delay'

__table_args__ = (
PrimaryKeyConstraint('id', 'timebin'),
PrimaryKeyConstraint('timebin','id'),
)

__hypertable__ = {
Expand Down
2 changes: 1 addition & 1 deletion models/atlas_delay_alarms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AtlasDelayAlarms(Base):
__tablename__ = 'ihr_atlas_delay_alarms'

__table_args__ = (
PrimaryKeyConstraint('id', 'timebin'),
PrimaryKeyConstraint('timebin','id'),
)

__hypertable__ = {
Expand Down
2 changes: 1 addition & 1 deletion models/atlas_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class AtlasLocation(Base):
__indexes__ = [
{
'name': 'ihr_atlas_location_af_name_type_idx',
'columns': ['af', 'name','type'],
'columns': ['af','type'],
},]
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(
Expand Down
2 changes: 1 addition & 1 deletion models/delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Delay(Base):
__tablename__ = 'ihr_delay'

__table_args__ = (
PrimaryKeyConstraint('id', 'timebin'),
PrimaryKeyConstraint('timebin','id'),
)

__hypertable__ = {
Expand Down
2 changes: 1 addition & 1 deletion models/delay_alarms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DelayAlarms(Base):
__tablename__ = 'ihr_delay_alarms'

__table_args__ = (
PrimaryKeyConstraint('id', 'timebin'),
PrimaryKeyConstraint('timebin','id'),
)

__indexes__ = [
Expand Down
2 changes: 1 addition & 1 deletion models/forwarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Forwarding(Base):
__tablename__ = 'ihr_forwarding'

__table_args__ = (
PrimaryKeyConstraint('id', 'timebin'),
PrimaryKeyConstraint('timebin','id'),
)

__hypertable__ = {
Expand Down
2 changes: 1 addition & 1 deletion models/forwarding_alarms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ForwardingAlarms(Base):
__tablename__ = 'ihr_forwarding_alarms'

__table_args__ = (
PrimaryKeyConstraint('id', 'timebin'),
PrimaryKeyConstraint('timebin','id'),
)

__indexes__ = [
Expand Down
2 changes: 1 addition & 1 deletion models/hegemony.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Hegemony(Base):
__tablename__ = 'ihr_hegemony'

__table_args__ = (
PrimaryKeyConstraint('id', 'timebin'),
PrimaryKeyConstraint('timebin','id'),
)

__hypertable__ = {
Expand Down
2 changes: 1 addition & 1 deletion models/hegemony_alarms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class HegemonyAlarms(Base):
__tablename__ = 'ihr_hegemony_alarms'

__table_args__ = (
PrimaryKeyConstraint('id', 'timebin'),
PrimaryKeyConstraint('timebin','id'),
)

__hypertable__ = {
Expand Down
2 changes: 1 addition & 1 deletion models/hegemony_cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class HegemonyCone(Base):
__tablename__ = 'ihr_hegemonycone'

__table_args__ = (
PrimaryKeyConstraint('id', 'timebin'),
PrimaryKeyConstraint('timebin','id'),
)

__indexes__ = [
Expand Down
2 changes: 1 addition & 1 deletion models/hegemony_country.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class HegemonyCountry(Base):
__tablename__ = 'ihr_hegemony_country'

__table_args__ = (
PrimaryKeyConstraint('id', 'timebin'),
PrimaryKeyConstraint('timebin','id'),
)

__hypertable__ = {
Expand Down
2 changes: 1 addition & 1 deletion models/hegemony_prefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class HegemonyPrefix(Base):
__tablename__ = 'ihr_hegemony_prefix'

__table_args__ = (
PrimaryKeyConstraint('id', 'timebin'),
PrimaryKeyConstraint('timebin','id'),
)

__hypertable__ = {
Expand Down
2 changes: 1 addition & 1 deletion models/metis_atlas_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class MetisAtlasDeployment(Base):
__tablename__ = 'ihr_metis_atlas_deployment'

__table_args__ = (
PrimaryKeyConstraint('id','timebin'),
PrimaryKeyConstraint('timebin','id'),
)

__hypertable__ = {
Expand Down
2 changes: 1 addition & 1 deletion models/metis_atlas_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class MetisAtlasSelection(Base):
__tablename__ = 'ihr_metis_atlas_selection'

__table_args__ = (
PrimaryKeyConstraint('id','timebin'),
PrimaryKeyConstraint('timebin','id'),
)

__hypertable__ = {
Expand Down
2 changes: 1 addition & 1 deletion models/tr_hegemony.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TRHegemony(Base):
__tablename__ = 'ihr_tr_hegemony'

__table_args__ = (
PrimaryKeyConstraint('id', 'timebin'),
PrimaryKeyConstraint('timebin','id'),
)

__hypertable__ = {
Expand Down
8 changes: 6 additions & 2 deletions repositories/atlas_delay_alarms_repository.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from sqlalchemy.orm import Session, aliased
from sqlalchemy.orm import Session, aliased, contains_eager
from sqlalchemy import and_, or_
from models.atlas_delay_alarms import AtlasDelayAlarms
from datetime import datetime
Expand Down Expand Up @@ -37,7 +37,11 @@ def get_alarms(

query = db.query(AtlasDelayAlarms)\
.join(Startpoint, AtlasDelayAlarms.startpoint_relation)\
.join(Endpoint, AtlasDelayAlarms.endpoint_relation)
.join(Endpoint, AtlasDelayAlarms.endpoint_relation)\
.options(
contains_eager(AtlasDelayAlarms.startpoint_relation, alias=Startpoint),
contains_eager(AtlasDelayAlarms.endpoint_relation, alias=Endpoint)
)


# If no time filters specified, get rows with max timebin
Expand Down
8 changes: 6 additions & 2 deletions repositories/atlas_delay_repository.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from sqlalchemy.orm import Session, aliased
from sqlalchemy.orm import Session, aliased, contains_eager
from sqlalchemy import and_, or_
from models.atlas_delay import AtlasDelay
from datetime import datetime
Expand Down Expand Up @@ -40,7 +40,11 @@ def get_delays(

query = db.query(AtlasDelay)\
.join(Startpoint, AtlasDelay.startpoint_relation)\
.join(Endpoint, AtlasDelay.endpoint_relation)
.join(Endpoint, AtlasDelay.endpoint_relation)\
.options(
contains_eager(AtlasDelay.startpoint_relation, alias=Startpoint),
contains_eager(AtlasDelay.endpoint_relation, alias=Endpoint)
)


# If no time filters specified, get rows with max timebin
Expand Down
13 changes: 11 additions & 2 deletions repositories/hegemony_alarms_repository.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from sqlalchemy.orm import Session
from sqlalchemy.orm import Session, aliased, contains_eager
from models.hegemony_alarms import HegemonyAlarms
from typing import Optional, List, Tuple
from utils import page_size
Expand All @@ -20,7 +20,16 @@ def get_all(
page: int = 1,
order_by: Optional[str] = None
) -> Tuple[List[HegemonyAlarms], int]:
query = db.query(HegemonyAlarms)
ASN = aliased(HegemonyAlarms.asn_relation.property.mapper.class_)
OriginASN = aliased(HegemonyAlarms.originasn_relation.property.mapper.class_)

query = db.query(HegemonyAlarms)\
.join(ASN, HegemonyAlarms.asn_relation)\
.join(OriginASN, HegemonyAlarms.originasn_relation)\
.options(
contains_eager(HegemonyAlarms.asn_relation, alias=ASN),
contains_eager(HegemonyAlarms.originasn_relation, alias=OriginASN)
)

# If no time filters specified, get rows with max timebin
if not timebin_gte and not timebin_lte:
Expand Down
10 changes: 8 additions & 2 deletions repositories/hegemony_country_repository.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from sqlalchemy.orm import Session
from sqlalchemy.orm import Session, contains_eager, aliased
from models.hegemony_country import HegemonyCountry
from typing import Optional, List, Tuple
from utils import page_size
Expand All @@ -23,7 +23,13 @@ def get_all(
page: int = 1,
order_by: Optional[str] = None
) -> Tuple[List[HegemonyCountry], int]:
query = db.query(HegemonyCountry)
ASN = aliased(HegemonyCountry.asn_relation.property.mapper.class_)

query = db.query(HegemonyCountry)\
.join(ASN, HegemonyCountry.asn_relation)\
.options(
contains_eager(HegemonyCountry.asn_relation, alias=ASN),
)

# If no time filters specified, get rows with max timebin
if not timebin_gte and not timebin_lte:
Expand Down
13 changes: 11 additions & 2 deletions repositories/hegemony_prefix_repository.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from sqlalchemy.orm import Session
from sqlalchemy.orm import Session, contains_eager, aliased
from models.hegemony_prefix import HegemonyPrefix
from typing import Optional, List, Tuple
from utils import page_size
Expand Down Expand Up @@ -28,8 +28,17 @@ def get_all(
page: int = 1,
order_by: Optional[str] = None
) -> Tuple[List[HegemonyPrefix], int]:
query = db.query(HegemonyPrefix)

ASN = aliased(HegemonyPrefix.asn_relation.property.mapper.class_)
OriginASN = aliased(HegemonyPrefix.originasn_relation.property.mapper.class_)

query = db.query(HegemonyPrefix)\
.join(ASN, HegemonyPrefix.asn_relation)\
.join(OriginASN, HegemonyPrefix.originasn_relation)\
.options(
contains_eager(HegemonyPrefix.asn_relation, alias=ASN),
contains_eager(HegemonyPrefix.originasn_relation, alias=OriginASN)
)
# If no time filters specified, get rows with max timebin
if not timebin_gte and not timebin_lte:
max_timebin = db.query(func.max(HegemonyPrefix.timebin)).scalar()
Expand Down
16 changes: 13 additions & 3 deletions repositories/hegemony_repository.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from sqlalchemy.orm import Session
from sqlalchemy.orm import Session, contains_eager, aliased
from models.hegemony import Hegemony
from typing import Optional, List, Tuple
from utils import page_size
Expand All @@ -21,8 +21,18 @@ def get_all(
page: int = 1,
order_by: Optional[str] = None
) -> Tuple[List[Hegemony], int]:
query = db.query(Hegemony)


ASN = aliased(Hegemony.asn_relation.property.mapper.class_)
OriginASN = aliased(Hegemony.originasn_relation.property.mapper.class_)

query = db.query(Hegemony)\
.join(ASN, Hegemony.asn_relation)\
.join(OriginASN, Hegemony.originasn_relation)\
.options(
contains_eager(Hegemony.asn_relation, alias=ASN),
contains_eager(Hegemony.originasn_relation, alias=OriginASN)
)

# If no time filters specified, get rows with max timebin
if not timebin_gte and not timebin_lte:
max_timebin = db.query(func.max(Hegemony.timebin)).scalar()
Expand Down
7 changes: 4 additions & 3 deletions repositories/metis_atlas_deployment_repository.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from sqlalchemy.orm import Session
from sqlalchemy.orm import Session, contains_eager
from models.metis_atlas_deployment import MetisAtlasDeployment
from typing import Optional, List, Tuple
from utils import page_size
Expand All @@ -21,8 +21,9 @@ def get_all(
page: int = 1,
order_by: Optional[str] = None
) -> Tuple[List[MetisAtlasDeployment], int]:
query = db.query(MetisAtlasDeployment).join(
MetisAtlasDeployment.asn_relation)
query = db.query(MetisAtlasDeployment)\
.join(MetisAtlasDeployment.asn_relation)\
.options(contains_eager(MetisAtlasDeployment.asn_relation))

# If no time filters specified, get rows with max timebin
if not timebin and not timebin_gte and not timebin_lte:
Expand Down
7 changes: 4 additions & 3 deletions repositories/metis_atlas_selection_repository.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from sqlalchemy.orm import Session
from sqlalchemy.orm import Session, contains_eager
from models.metis_atlas_selection import MetisAtlasSelection
from typing import Optional, List, Tuple
from utils import page_size
Expand All @@ -21,8 +21,9 @@ def get_all(
page: int = 1,
order_by: Optional[str] = None
) -> Tuple[List[MetisAtlasSelection], int]:
query = db.query(MetisAtlasSelection).join(
MetisAtlasSelection.asn_relation)
query = db.query(MetisAtlasSelection)\
.join(MetisAtlasSelection.asn_relation)\
.options(contains_eager(MetisAtlasSelection.asn_relation))

# If no time filters specified, get rows with max timebin
if not timebin and not timebin_gte and not timebin_lte:
Expand Down
8 changes: 6 additions & 2 deletions repositories/tr_hegemony_repository.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from sqlalchemy.orm import Session, aliased
from sqlalchemy.orm import Session, aliased, contains_eager
from sqlalchemy import and_, or_
from models.tr_hegemony import TRHegemony
from datetime import datetime
Expand Down Expand Up @@ -34,7 +34,11 @@ def get_tr_hegemony(

query = db.query(TRHegemony)\
.join(Origin, TRHegemony.origin_relation)\
.join(Dependency, TRHegemony.dependency_relation)
.join(Dependency, TRHegemony.dependency_relation)\
.options(
contains_eager(TRHegemony.origin_relation, alias=Origin),
contains_eager(TRHegemony.dependency_relation, alias=Dependency)
)

# If no time filters specified, get rows with max timebin
if not timebin and not timebin_gte and not timebin_lte:
Expand Down