Skip to content

Commit

Permalink
Add missing index
Browse files Browse the repository at this point in the history
  • Loading branch information
russss committed May 31, 2024
1 parent 75e9ac6 commit 085d10b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
34 changes: 34 additions & 0 deletions migrations/versions/e9c68e8f78c2_add_index_to_favouriteproposal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Add index to FavouriteProposal
Revision ID: e9c68e8f78c2
Revises: e27e0646278c
Create Date: 2024-05-31 21:43:02.680838
"""

# revision identifiers, used by Alembic.
revision = 'e9c68e8f78c2'
down_revision = 'e27e0646278c'

from alembic import op
import sqlalchemy as sa


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_index(op.f('ix_favourite_proposal_proposal_id'), 'favourite_proposal', ['proposal_id'], unique=False)
op.alter_column('feature_flag_version', 'enabled',
existing_type=sa.BOOLEAN(),
nullable=True,
autoincrement=False)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('feature_flag_version', 'enabled',
existing_type=sa.BOOLEAN(),
nullable=False,
autoincrement=False)
op.drop_index(op.f('ix_favourite_proposal_proposal_id'), table_name='favourite_proposal')
# ### end Alembic commands ###
19 changes: 15 additions & 4 deletions models/cfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,11 @@ class InvalidVenueException(Exception):
BaseModel.metadata,
db.Column("user_id", db.Integer, db.ForeignKey("user.id"), primary_key=True),
db.Column(
"proposal_id", db.Integer, db.ForeignKey("proposal.id"), primary_key=True
"proposal_id",
db.Integer,
db.ForeignKey("proposal.id"),
primary_key=True,
index=True,
),
)

Expand Down Expand Up @@ -753,8 +757,10 @@ def get_conflicting_content(self) -> list["Proposal"]:
Proposal.scheduled_time.is_not(None),
Proposal.scheduled_duration.is_not(None),
).all()
if self.scheduled_time + timedelta(minutes=self.scheduled_duration) > p.scheduled_time and
p.scheduled_time + timedelta(minutes=p.scheduled_duration) > self.scheduled_time
if self.scheduled_time + timedelta(minutes=self.scheduled_duration)
> p.scheduled_time
and p.scheduled_time + timedelta(minutes=p.scheduled_duration)
> self.scheduled_time
]

@property
Expand Down Expand Up @@ -802,7 +808,12 @@ def latlon(self):
def map_link(self) -> Optional[str]:
latlon = self.latlon
if latlon:
return "https://map.emfcamp.org/#18.5/%s/%s/m=%s,%s" % (latlon[0], latlon[1], latlon[0], latlon[1])
return "https://map.emfcamp.org/#18.5/%s/%s/m=%s,%s" % (
latlon[0],
latlon[1],
latlon[0],
latlon[1],
)
return None

@property
Expand Down

0 comments on commit 085d10b

Please sign in to comment.