mirror of
https://github.com/lucaspalomodevelop/indico-plugins.git
synced 2026-03-14 16:04:36 +00:00
VC/Vidyo: Adapt to IndexedEvent removal
This commit is contained in:
parent
e406577055
commit
c0d5899e78
@ -23,9 +23,9 @@ from celery.schedules import crontab
|
||||
from indico.core.celery import celery
|
||||
from indico.core.db import db
|
||||
from indico.core.plugins import get_plugin_template_module
|
||||
from indico.modules.events import Event
|
||||
from indico.modules.vc.models.vc_rooms import VCRoomEventAssociation, VCRoom, VCRoomStatus
|
||||
from indico.modules.vc.notifications import _send
|
||||
from indico.modules.fulltextindexes.models.events import IndexedEvent
|
||||
from indico.util.date_time import now_utc
|
||||
from indico.util.struct.iterables import committing_iterator
|
||||
from indico_vc_vidyo.api import APIException, RoomNotFoundAPIException
|
||||
@ -36,12 +36,12 @@ def find_old_vidyo_rooms(max_room_event_age):
|
||||
- linked to no events
|
||||
- linked only to events whose start date precedes today - max_room_event_age days
|
||||
"""
|
||||
recently_used = db.session.query(VCRoom.id).filter(
|
||||
VCRoom.type == 'vidyo',
|
||||
IndexedEvent.end_date > (now_utc() - timedelta(days=max_room_event_age))
|
||||
).join(VCRoomEventAssociation).join(
|
||||
IndexedEvent, IndexedEvent.id == VCRoomEventAssociation.event_id
|
||||
).group_by(VCRoom.id)
|
||||
recently_used = (db.session.query(VCRoom.id)
|
||||
.filter(VCRoom.type == 'vidyo',
|
||||
Event.end_dt > (now_utc() - timedelta(days=max_room_event_age)))
|
||||
.join(VCRoomEventAssociation)
|
||||
.join(Event)
|
||||
.group_by(VCRoom.id))
|
||||
|
||||
# non-deleted rooms with no recent associations
|
||||
return VCRoom.find_all(VCRoom.status != VCRoomStatus.deleted, ~VCRoom.id.in_(recently_used))
|
||||
|
||||
@ -17,9 +17,10 @@
|
||||
from datetime import datetime
|
||||
|
||||
import pytest
|
||||
from pytz import utc
|
||||
|
||||
from indico.modules.fulltextindexes.models.events import IndexedEvent
|
||||
from indico.modules.vc.models.vc_rooms import VCRoom, VCRoomEventAssociation, VCRoomStatus, VCRoomLinkType
|
||||
|
||||
from indico_vc_vidyo.models.vidyo_extensions import VidyoExtension
|
||||
|
||||
|
||||
@ -61,16 +62,15 @@ def create_dummy_room(db, dummy_avatar):
|
||||
return _create_room
|
||||
|
||||
|
||||
def test_room_cleanup(create_dummy_room, dummy_avatar, freeze_time, db):
|
||||
def test_room_cleanup(create_event, create_dummy_room, dummy_avatar, freeze_time, db):
|
||||
"""Test that 'old' Vidyo rooms are correctly detected"""
|
||||
freeze_time(datetime(2015, 2, 1))
|
||||
|
||||
for id_, (evt_name, end_date) in enumerate((('Event one', datetime(2012, 1, 1)),
|
||||
('Event two', datetime(2013, 1, 1)),
|
||||
('Event three', datetime(2014, 1, 1)),
|
||||
('Event four', datetime(2015, 1, 1))), start=1):
|
||||
idx = IndexedEvent(id=id_, title=evt_name, end_date=end_date, start_date=end_date)
|
||||
db.session.add(idx)
|
||||
for id_, (evt_name, end_date) in enumerate((('Event one', datetime(2012, 1, 1, tzinfo=utc)),
|
||||
('Event two', datetime(2013, 1, 1, tzinfo=utc)),
|
||||
('Event three', datetime(2014, 1, 1, tzinfo=utc)),
|
||||
('Event four', datetime(2015, 1, 1, tzinfo=utc))), start=1):
|
||||
create_event(id_, title=evt_name, end_dt=end_date, start_dt=end_date)
|
||||
|
||||
for id_, (vidyo_id, extension, evt_ids) in enumerate(((1234, 5678, (1, 2, 3, 4)),
|
||||
(1235, 5679, (1, 2)),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user