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
29 changes: 27 additions & 2 deletions discovery-provider/src/queries/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Block,
ChallengeDisbursement,
Follow,
Milestone,
Playlist,
Remix,
Repost,
Expand All @@ -20,8 +21,8 @@
SupporterRankUp,
Track,
UserBalanceChange,
UserTip,
)
from src.models.milestone import Milestone
from src.queries import response_name_constants as const
from src.queries.get_prev_track_entries import get_prev_track_entries
from src.queries.get_sol_rewards_manager import (
Expand Down Expand Up @@ -1020,7 +1021,7 @@ def get_max_slot(redis: Redis):
f"notifications.py | get_max_slot() | listen_milestone_slot:{listen_milestone_slot} rewards_manager_slot:{rewards_manager_slot} supporter_rank_up_slot:{supporter_rank_up_slot}"
)
if len(all_slots) == 0:
return None
return 0
return min(all_slots)


Expand Down Expand Up @@ -1140,9 +1141,33 @@ def solana_notifications():
}
)

user_tips_result: List[UserTip] = (
session.query(UserTip)
.filter(
UserTip.slot >= min_slot_number,
UserTip.slot <= max_slot_number,
)
.all()
)
tips = []
for user_tip in user_tips_result:
tips.append(
{
const.solana_notification_type: const.solana_notification_type_tip,
const.solana_notification_slot: user_tip.slot,
const.solana_notification_initiator: user_tip.receiver_user_id,
const.solana_notification_metadata: {
const.notification_entity_id: user_tip.sender_user_id,
const.notification_entity_type: "user",
const.solana_notification_tip_amount: str(user_tip.amount),
},
}
)

notifications_unsorted.extend(challenge_reward_notifications)
notifications_unsorted.extend(track_listen_milestones)
notifications_unsorted.extend(supporter_rank_ups)
notifications_unsorted.extend(tips)

# Final sort
sorted_notifications = sorted(
Expand Down
2 changes: 2 additions & 0 deletions discovery-provider/src/queries/response_name_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
solana_notification_type_challenge_reward = "ChallengeReward"
solana_notification_type_listen_milestone = "MilestoneListen"
solana_notification_type_supporter_rank_up = "SupporterRankUp"
solana_notification_type_tip = "Tip"

solana_notification_slot = "slot"
solana_notification_timestamp = "timestamp"
Expand All @@ -119,6 +120,7 @@
solana_notification_challenge_id = "challenge_id"
solana_notification_threshold = "threshold"
solana_notification_tip_rank = "rank"
solana_notification_tip_amount = "amount"

# Trending
owner_follower_count = "owner_follower_count"