| Total Complexity | 8 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Coverage | 80% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | 1 | class Handler(object): |
|
| 20 | 1 | class SessionHandler(Handler): |
|
| 21 | 1 | @staticmethod |
|
| 22 | def has_finished(session, payload): |
||
| 23 | 1 | if not session or not session.duration: |
|
| 24 | return False |
||
| 25 | |||
| 26 | # Calculate session progress |
||
| 27 | 1 | # TODO update to support multi-part sessions |
|
|
|
|||
| 28 | progress = float(payload.get('view_offset')) / session.duration |
||
| 29 | |||
| 30 | 1 | # Session is finished when `progress` reaches at least 100% |
|
| 31 | return progress >= 1.0 |
||
| 32 | 1 | ||
| 33 | @staticmethod |
||
| 34 | 1 | def has_media_changed(session, payload): |
|
| 35 | if not session or not session.rating_key: |
||
| 36 | return False |
||
| 37 | 1 | ||
| 38 | if session.rating_key != payload.get('rating_key'): |
||
| 39 | return True |
||
| 40 | |||
| 41 | if session.part != payload.get('part', 1): |
||
| 42 | return True |
||
| 43 | |||
| 44 | return False |
||
| 45 |