':param limit: The maximum number of elements to return
:param action: The type of action to filter in the history. Either \'downloaded\' or \'snatched\'. Anything else or
no value will return everything (up to ``limit``)
:return: The last ``limit`` elements of type ``action`` in the history'

def get(self, limit=100, action=None):

    actions = History._get_actions(action)
    limit = History._get_limit(limit)
    common_sql = u'SELECT    action,    date,    episode,    provider,    h.quality,    resource,    season,    show_name,    showid    FROM    history    h,    tv_shows    s    WHERE    h.showid    =    s.indexer_id    '
    filter_sql = ((u'AND    action    in    (' + u','.join(([u'?'] * len(actions)))) + u')    ')
    order_sql = u'ORDER    BY    date    DESC    '
    if (limit == 0):
        if actions:
            results = self.db.select(((common_sql + filter_sql) + order_sql), actions)
        else:
            results = self.db.select((common_sql + order_sql))
    elif actions:
        results = self.db.select((((common_sql + filter_sql) + order_sql) + u'LIMIT    ?'), (actions + [limit]))
    else:
        results = self.db.select(((common_sql + order_sql) + u'LIMIT    ?'), [limit])
    data = []
    for result in results:
        data.append({u'action': result['action'], u'date': result['date'], u'episode': result['episode'], u'provider': result['provider'], u'quality': result['quality'], u'resource': result['resource'], u'season': result['season'], u'show_id': result['showid'], u'show_name': result['show_name']})
    return data
