557aef062fd907e6dec11acfa5525d2d859d29a7,dino/db/rdbms/handler.py,DatabaseRdbms,leave_room,#DatabaseRdbms#Any#Any#,245

Before Change



    @with_session
    def leave_room(self, user_id: str, room_id: str) -> None:
        raise NotImplementedError()

    @with_session
    def join_room(self, user_id: str, user_name: str, room_id: str, room_name: str) -> None:
        room = self.session.query(Rooms).filter(Rooms.uuid == room_id).first()

After Change



    @with_session
    def leave_room(self, user_id: str, room_id: str) -> None:
        room = self.session.query(Rooms).filter(Rooms.uuid == room_id).first()
        if room is None:
            raise NoSuchRoomException(room_id)

        user = self.session.query(Users)\
            .join(Users.rooms)\
            .filter(Users.uuid == user_id)\
            .filter(Rooms.uuid == room_id)\
            .first()

        if user is None:
            // user is not in the room, so nothing to do
            return

        room = user.rooms[0]
        room.users.remove(user)
        self.session.commit()
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 14

Instances


Project Name: thenetcircle/dino
Commit Name: 557aef062fd907e6dec11acfa5525d2d859d29a7
Time: 2016-10-19
Author: oscar.eriks@gmail.com
File Name: dino/db/rdbms/handler.py
Class Name: DatabaseRdbms
Method Name: leave_room


Project Name: thenetcircle/dino
Commit Name: 325ba2c0857d2fff5d1915260bd58af571941609
Time: 2016-10-18
Author: oscar.eriks@gmail.com
File Name: dino/db/postgres/postgres.py
Class Name: DatabasePostgres
Method Name: room_owners_contain


Project Name: thenetcircle/dino
Commit Name: 6279a1e15c55b651bb5669546483a6c551552c6b
Time: 2016-10-19
Author: oscar.eriks@gmail.com
File Name: dino/db/rdbms/handler.py
Class Name: DatabaseRdbms
Method Name: delete_acl


Project Name: thenetcircle/dino
Commit Name: 557aef062fd907e6dec11acfa5525d2d859d29a7
Time: 2016-10-19
Author: oscar.eriks@gmail.com
File Name: dino/db/rdbms/handler.py
Class Name: DatabaseRdbms
Method Name: leave_room