Skip to content

Commit

Permalink
Feh!
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Nov 26, 2020
1 parent 59cb717 commit acc8db9
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions mautrix_telegram/db/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from typing import Optional, Iterable

from sqlalchemy import Column, Integer, String, Boolean, Text, func, sql, select
from sqlalchemy import Column, Integer, String, Boolean, Text, Table, MetaData, func, sql, select

from mautrix.types import RoomID, ContentURI
from mautrix.util.db import Base
Expand Down Expand Up @@ -55,12 +55,8 @@ def find_private_chats(cls, tg_receiver: TelegramID) -> Iterable['Portal']:

@classmethod
def count(cls) -> int:
rows = cls.db.execute(select([func.count()]))
try:
count, = next(rows)
return count
except StopIteration:
return 0
count = cls.db.execute(select([func.count('*')]).select_from(Table("portal", MetaData()))).scalar()
return count

@classmethod
def get_by_mxid(cls, mxid: RoomID) -> Optional['Portal']:
Expand Down

0 comments on commit acc8db9

Please sign in to comment.