from framework.controller import log

# find keywords in a string
def getKeywords(db, s):
    """Get all matches for passed in string in keyword tables
    
    :param db: database handle
    :param s:  string to look for
    :returns   list of matching keywords
    """
    words = []
    if isinstance(s, str): s = [s]
    if not isinstance(s, list):
        log.error("getKeywords requested for a non-string, non-list value: %s. Cannot process!" % s)
    else:
        words = list(db.query("select keyword from keyword where keyword in $lookfor", vars=dict(lookfor=s)))

    return words


# find keywords in a string
def getKeywords(db, s):
    sql = "select keyword from keyword"
    data = list(db.query(sql))
    
    words = []
    
    for d in data:
        if (d.keyword in s):
            words.append(d.keyword)
            
    return words

Revert keyword optimization for current release
Revert keyword optimization for current release
- from framework.controller import log
  
  # find keywords in a string
  def getKeywords(db, s):
-     """Get all matches for passed in string in keyword tables
+     sql = "select keyword from keyword"
+     data = list(db.query(sql))
      
-     :param db: database handle
-     :param s:  string to look for
-     :returns   list of matching keywords
-     """
      words = []
+     
+     for d in data:
+         if (d.keyword in s):
+             words.append(d.keyword)
+             
-     if isinstance(s, str): s = [s]
-     if not isinstance(s, list):
-         log.error("getKeywords requested for a non-string, non-list value: %s. Cannot process!" % s)
-     else:
-         words = list(db.query("select keyword from keyword where keyword in $lookfor", vars=dict(lookfor=s)))
- 
      return words
  
Revert keyword optimization for current release
## Code Before:
from framework.controller import log

# find keywords in a string
def getKeywords(db, s):
    """Get all matches for passed in string in keyword tables
    
    :param db: database handle
    :param s:  string to look for
    :returns   list of matching keywords
    """
    words = []
    if isinstance(s, str): s = [s]
    if not isinstance(s, list):
        log.error("getKeywords requested for a non-string, non-list value: %s. Cannot process!" % s)
    else:
        words = list(db.query("select keyword from keyword where keyword in $lookfor", vars=dict(lookfor=s)))

    return words

## Instruction:
Revert keyword optimization for current release
## Code After:

# find keywords in a string
def getKeywords(db, s):
    sql = "select keyword from keyword"
    data = list(db.query(sql))
    
    words = []
    
    for d in data:
        if (d.keyword in s):
            words.append(d.keyword)
            
    return words
