# Path: qpanel/model.py
# class QueueLog(DeclarativeBase):
#     def as_dict(self):
# def queuelog_event_by_range_and_types(start_date, end_date, events=None,
#                                       agent=None, queue=None):
# def queuelog_count_answered(start_date, end_date, agent=None, queue=None):
# def queuelog_count_inbound(start_date, end_date, agent=None, queue=None):
# def queuelog_count_abandon(start_date, end_date, agent=None, queue=None):
# def queuelog_seconds_wait_abandon(start_date, end_date, agent=None,
#                                   queue=None):
# def queuelog_seconds_wait(start_date, end_date, agent=None, queue=None):
# def queuelog_seconds_talking(start_date, end_date, agent=None, queue=None):
# def parse_list_record(list):
# def queuelog_insert(log):
# def queuelog_exists_record(log):
# def queuelog_data_queue(from_date, to_date, agent=None, queue=None):


import sys
import tailer
import click
from qpanel import model
        else:
            nlines = int(lines)
            content = tailer.tail(open(file), nlines)
        print('Reading file %s ...' % file)

    except IOError:
        print('File file %s not exits or not can read.' % file)
        sys.exit(1)

    for idx, line in enumerate(content):
        record = line.split('|')
        if len(record) < 4:
            continue
        if not exist_record(record) and insert_record(record):
            inserted += 1
            if verbose:
                print(('Insert record ', record))
        else:
            if verbose:
                print(('Not insert record ', record))
            not_inserted += 1
    print('Insert record: %i\nNo inserted record: %i' % (inserted,
                                                         not_inserted))


def exist_record(record):
    return model.queuelog_exists_record(record)


def insert_record(record):

# Path: qpanel/model.py
# class QueueLog(DeclarativeBase):
#     def as_dict(self):
# def queuelog_event_by_range_and_types(start_date, end_date, events=None,
#                                       agent=None, queue=None):
# def queuelog_count_answered(start_date, end_date, agent=None, queue=None):
# def queuelog_count_inbound(start_date, end_date, agent=None, queue=None):
# def queuelog_count_abandon(start_date, end_date, agent=None, queue=None):
# def queuelog_seconds_wait_abandon(start_date, end_date, agent=None,
#                                   queue=None):
# def queuelog_seconds_wait(start_date, end_date, agent=None, queue=None):
# def queuelog_seconds_talking(start_date, end_date, agent=None, queue=None):
# def parse_list_record(list):
# def queuelog_insert(log):
# def queuelog_exists_record(log):
# def queuelog_data_queue(from_date, to_date, agent=None, queue=None):


# Path: parser_queuelog.py
import sys
import tailer
import click
from qpanel import model

        else:
            nlines = int(lines)
            content = tailer.tail(open(file), nlines)
        print('Reading file %s ...' % file)

    except IOError:
        print('File file %s not exits or not can read.' % file)
        sys.exit(1)

    for idx, line in enumerate(content):
        record = line.split('|')
        if len(record) < 4:
            continue
        if not exist_record(record) and insert_record(record):
            inserted += 1
            if verbose:
                print(('Insert record ', record))
        else:
            if verbose:
                print(('Not insert record ', record))
            not_inserted += 1
    print('Insert record: %i\nNo inserted record: %i' % (inserted,
                                                         not_inserted))


def exist_record(record):
    return model.queuelog_exists_record(record)


def insert_record(record):

    return model.queuelog_insert(record)