Coverage for polar/models/notification_recipient.py: 89%

16 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-12-05 16:17 +0000

1from typing import TYPE_CHECKING 1ab

2from uuid import UUID 1ab

3 

4from sqlalchemy import ForeignKey, Index, String, Uuid 1ab

5from sqlalchemy.orm import Mapped, declared_attr, mapped_column, relationship 1ab

6 

7from polar.kit.db.models.base import RecordModel 1ab

8 

9if TYPE_CHECKING: 9 ↛ 10line 9 didn't jump to line 10 because the condition on line 9 was never true1ab

10 from .user import User 

11 

12 

13class NotificationRecipient(RecordModel): 1ab

14 __tablename__ = "notification_recipients" 1ab

15 __table_args__ = ( 1ab

16 Index( 

17 "ix_notification_recipients_expo_push_token", 

18 "user_id", 

19 "expo_push_token", 

20 "deleted_at", 

21 unique=True, 

22 postgresql_nulls_not_distinct=True, 

23 ), 

24 ) 

25 

26 user_id: Mapped[UUID] = mapped_column( 1ab

27 Uuid, ForeignKey("users.id", ondelete="cascade") 

28 ) 

29 platform: Mapped[str] = mapped_column(String, nullable=False) 1ab

30 expo_push_token: Mapped[str] = mapped_column( 1ab

31 String, 

32 nullable=False, 

33 ) 

34 

35 @declared_attr 1ab

36 def user(cls) -> Mapped["User"]: 1ab

37 return relationship("User", lazy="raise_on_sql") 1ab