Skip to content

Commit 35a53b0

Browse files
authored
Merge pull request #410 from VariantEffect/maintenance/bencap/rework-indices-on-published-variants-mv
Simplify Published Variant MV Indexes
2 parents 096b851 + 806eb40 commit 35a53b0

File tree

2 files changed

+80
-1
lines changed

2 files changed

+80
-1
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
"""simplify published variants mv indexes
2+
3+
Revision ID: 4726e4dddde8
4+
Revises: b85bc7b1bec7
5+
Create Date: 2025-03-25 10:46:46.641777
6+
7+
"""
8+
9+
from alembic import op
10+
11+
from mavedb.models.published_variant import signature
12+
13+
14+
# revision identifiers, used by Alembic.
15+
revision = "4726e4dddde8"
16+
down_revision = "b85bc7b1bec7"
17+
branch_labels = None
18+
depends_on = None
19+
20+
21+
def upgrade():
22+
# ### commands auto generated by Alembic - please adjust! ###
23+
op.drop_index(f"idx_{signature}_variant_id", signature)
24+
op.drop_index(f"idx_{signature}_variant_urn", signature)
25+
op.drop_index(f"idx_{signature}_mapped_variant_id", signature)
26+
op.drop_index(f"idx_{signature}_score_set_id", signature)
27+
op.drop_index(f"idx_{signature}_score_set_urn", signature)
28+
29+
op.create_index(
30+
f"idx_{signature}_ids",
31+
signature,
32+
["mapped_variant_id", "variant_id", "score_set_id"],
33+
unique=True,
34+
)
35+
# ### end Alembic commands ###
36+
37+
38+
def downgrade():
39+
# ### commands auto generated by Alembic - please adjust! ###
40+
op.drop_index(f"idx_{signature}_ids", signature)
41+
42+
op.create_index(
43+
f"idx_{signature}_variant_id",
44+
signature,
45+
["variant_id"],
46+
unique=False,
47+
)
48+
op.create_index(
49+
f"idx_{signature}_variant_urn",
50+
signature,
51+
["variant_urn"],
52+
unique=False,
53+
)
54+
op.create_index(
55+
f"idx_{signature}_score_set_id",
56+
signature,
57+
["score_set_id"],
58+
unique=False,
59+
)
60+
op.create_index(
61+
f"idx_{signature}_score_set_urn",
62+
signature,
63+
["score_set_urn"],
64+
unique=False,
65+
)
66+
op.create_index(
67+
f"idx_{signature}_mapped_variant_id",
68+
signature,
69+
["mapped_variant_id"],
70+
unique=True,
71+
)
72+
# ### end Alembic commands ###

src/mavedb/worker/settings.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
from concurrent import futures
3+
from datetime import timedelta
34
from typing import Callable
45

56
from arq.connections import RedisSettings
@@ -26,7 +27,13 @@
2627
# In UTC time. Depending on daylight savings time, this will bounce around by an hour but should always be very early in the morning
2728
# for all of the USA.
2829
BACKGROUND_CRONJOBS: list[CronJob] = [
29-
cron(refresh_materialized_views, name="refresh_all_materialized_views", hour=20, minute=0)
30+
cron(
31+
refresh_materialized_views,
32+
name="refresh_all_materialized_views",
33+
hour=20,
34+
minute=0,
35+
keep_result=timedelta(minutes=2).total_seconds(),
36+
)
3037
]
3138

3239
REDIS_IP = os.getenv("REDIS_IP") or "localhost"

0 commit comments

Comments
 (0)