Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""DB-only scheduled release publish (parity with @pedalboard/publish-scheduled-releases).

Used by integration tests after Celery task removal from discovery-provider.
"""

from sqlalchemy import func

from src.models.playlists.playlist import Playlist
from src.models.tracks.track import Track
from src.tasks.entity_manager.utils import create_remix_contest_notification

batch_size = 100


def publish_scheduled_releases_session(session):
tracks_to_release = (
session.query(Track)
.filter(
Track.is_unlisted == True,
Track.is_scheduled_release == True,
Track.release_date != None,
Track.release_date < func.current_timestamp(),
)
.order_by(Track.created_at.asc())
.limit(batch_size)
.all()
)
if len(tracks_to_release) == 0:
pass
else:
for track in tracks_to_release:
track.is_unlisted = False
create_remix_contest_notification(session, track)

playlists_to_release = (
session.query(Playlist)
.filter(
Playlist.is_private == True,
Playlist.is_album == True,
Playlist.is_scheduled_release == True,
Playlist.release_date != None,
Playlist.release_date < func.current_timestamp(),
)
.order_by(Playlist.created_at.asc())
.limit(batch_size)
.all()
)

for playlist in playlists_to_release:
playlist.is_private = False
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
from web3.datastructures import AttributeDict

from integration_tests.challenges.index_helpers import UpdateTask
from integration_tests.tasks.publish_scheduled_releases_helpers import (
publish_scheduled_releases_session,
)
from integration_tests.utils import populate_mock_db
from src.challenges.challenge_event_bus import ChallengeEventBus, setup_challenge_bus
from src.models.notifications.notification import Notification
from src.models.tracks.track import Track
from src.queries.get_notifications import NotificationType
from src.tasks.entity_manager.entity_manager import entity_manager_update
from src.tasks.publish_scheduled_releases import _publish_scheduled_releases
from src.utils.db_session import get_db

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -532,7 +534,7 @@ def test_fan_remix_contest_started_notification_on_scheduled_release(app):
assert len(notifications) == 0

# Run the scheduled release publish
_publish_scheduled_releases(session)
publish_scheduled_releases_session(session)

# Verify track was made public
track = session.query(Track).filter_by(track_id=TEST_TRACK_ID).first()
Expand Down Expand Up @@ -777,7 +779,7 @@ def test_fan_remix_contest_started_notification_no_duplicate_on_scheduled_releas

with db.scoped_session() as session:
# Run the scheduled release publish
_publish_scheduled_releases(session)
publish_scheduled_releases_session(session)

# Verify track was made public
track = session.query(Track).filter_by(track_id=TEST_TRACK_ID).first()
Expand Down Expand Up @@ -1049,7 +1051,7 @@ def test_fan_remix_contest_started_notification_no_duplicate_with_existing_on_sc
assert notifications_before[0].user_ids == [FOLLOWER_ID]

# Run the scheduled release publish
_publish_scheduled_releases(session)
publish_scheduled_releases_session(session)

# Verify track was made public
track = session.query(Track).filter_by(track_id=TEST_TRACK_ID).first()
Expand Down
6 changes: 0 additions & 6 deletions packages/discovery-provider/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ def configure_celery(celery, test_config=None):
"src.tasks.cache_current_nodes",
"src.tasks.update_aggregates",
"src.tasks.cache_entity_counts",
"src.tasks.publish_scheduled_releases",
"src.tasks.create_engagement_notifications",
"src.tasks.create_listen_streak_reminder_notifications",
"src.tasks.create_remix_contest_notifications",
Expand Down Expand Up @@ -380,10 +379,6 @@ def configure_celery(celery, test_config=None):
"task": "update_aggregates",
"schedule": timedelta(minutes=10),
},
"publish_scheduled_releases": {
"task": "publish_scheduled_releases",
"schedule": timedelta(minutes=1),
},
"create_engagement_notifications": {
"task": "create_engagement_notifications",
"schedule": timedelta(minutes=10),
Expand Down Expand Up @@ -450,7 +445,6 @@ def configure_celery(celery, test_config=None):
redis_inst.delete(UPDATE_DELIST_STATUSES_LOCK)
redis_inst.delete(REPAIR_AUDIO_ANALYSES_LOCK)
redis_inst.delete("update_aggregates_lock")
redis_inst.delete("publish_scheduled_releases_lock")
redis_inst.delete("create_engagement_notifications")
redis_inst.delete(index_core_lock_key)
# delete cached final_poa_block in case it has changed
Expand Down

This file was deleted.