Coverage for dibbler / models / LastCacheTransaction.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-01-25 14:26 +0000

1from __future__ import annotations 

2from typing import TYPE_CHECKING 

3 

4from sqlalchemy import Integer, ForeignKey 

5from sqlalchemy.orm import Mapped, mapped_column, relationship 

6 

7from dibbler.models import Base 

8 

9if TYPE_CHECKING: 

10 from dibbler.models import Transaction 

11 

12 

13class LastCacheTransaction(Base): 

14 """Tracks the last transaction that affected various caches.""" 

15 

16 id: Mapped[int] = mapped_column(Integer, primary_key=True) 

17 """Internal database ID""" 

18 

19 transaction_id: Mapped[int | None] = mapped_column(ForeignKey("trx.id"), index=True) 

20 """The ID of the last transaction that affected the cache(s).""" 

21 

22 transaction: Mapped[Transaction | None] = relationship( 

23 lazy="joined", 

24 foreign_keys=[transaction_id], 

25 ) 

26 """The last transaction that affected the cache(s)."""