| Total Complexity | 8 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Coverage | 78.56% |
| 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 | # TODO update to support multi-part sessions |
||
|
|
|||
| 28 | 1 | progress = float(payload.get('view_offset')) / session.duration |
|
| 29 | |||
| 30 | # Session is finished when `progress` reaches at least 100% |
||
| 31 | 1 | return progress >= 1.0 |
|
| 32 | |||
| 33 | 1 | @staticmethod |
|
| 34 | def has_media_changed(session, payload): |
||
| 35 | 1 | if not session or not session.rating_key: |
|
| 36 | return False |
||
| 37 | |||
| 38 | 1 | if session.rating_key != payload.get('rating_key'): |
|
| 39 | 1 | return True |
|
| 40 | |||
| 41 | 1 | if session.part != payload.get('part', 1): |
|
| 42 | return True |
||
| 43 | |||
| 44 | return False |
||
| 45 |