Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove untested __statement_filter method #1194

Merged
merged 1 commit into from
Jan 31, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions chatterbot/storage/sql_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,23 +121,14 @@ def count(self):
session.close()
return statement_count

def __statement_filter(self, session, **kwargs):
"""
Apply filter operation on Statement

rtype: query
"""
Statement = self.get_model('statement')

_query = session.query(Statement)
return _query.filter_by(**kwargs)

def find(self, statement_text):
"""
Returns a statement if it exists otherwise None
"""
Statement = self.get_model('statement')
session = self.Session()
query = self.__statement_filter(session, **{"text": statement_text})

query = session.query(Statement).filter_by(text=statement_text)
record = query.first()
if record:
statement = record.get_statement()
Expand All @@ -153,8 +144,10 @@ def remove(self, statement_text):
Removes any responses from statements where the response text matches
the input text.
"""
Statement = self.get_model('statement')
session = self.Session()
query = self.__statement_filter(session, **{"text": statement_text})

query = session.query(Statement).filter_by(text=statement_text)
record = query.first()

session.delete(record)
Expand Down Expand Up @@ -238,7 +231,8 @@ def update(self, statement):

if statement:
session = self.Session()
query = self.__statement_filter(session, **{"text": statement.text})

query = session.query(Statement).filter_by(text=statement.text)
record = query.first()

# Create a new statement entry if one does not already exist
Expand Down