예제 #1
0
#logger.set_param('covid_maker.log')
conn = args.connection

# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    #args.date_start, args.date_end = ('2021-06-01','2021-06-02')
    t0 = timer.get_time()
    report = DIT_report(args.date_start, args.date_end, args.config,
                        args.output, args.contract)
    report.tunnels.start()
    #tunnel_cfg = report.get_config_db('sshtunnel')

    #список шаблонов
    query = "SELECT message_template_id FROM message_template_tag WHERE tag_id=(select id from tag where text = %s ) ORDER BY message_template_id;"
    logger.log(f"Query: {query}, {args.contract}", 'INFO', args.verbose)
    report.set_db('postgres', 'tmpl')
    tmpl_list = [
        i[0] for i in report.get_db().call_select(query, args.contract)
    ]
    logger.log(f"Result: {tmpl_list}", 'INFO', args.verbose)

    # Получаем списки UUID сообщений с нужными  шаблонами
    date_list = report.get_time_period('10min')
    print(date_list)
    report.set_db('postgres', 'mapi')
    uuids = []
    for item in date_list:
        date_start = item['date_start']
        date_end = item['date_end']
        tmpls = tuple(tmpl_list)
        query = f"SELECT message_uuid FROM new_message WHERE created>='{date_start}' AND created<'{date_end}' AND " \
예제 #2
0
#logger.set_param('covid_maker.log')

# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    t0 = timer.get_time()
    report = DIT_report(args.date_start, args.date_end, args.config,
                        args.output, args.contract)
    date_list = report.get_time_period('10min')
    logger.log(len(date_list), 'INFO', args.verbose)
    res_data = dict(select=0, all=0, insert=0, update=0)
    for item in date_list:
        date_start = item['date_start']
        date_end = item['date_end']
        query = f"SELECT * FROM insert_messages_by_period('{date_start}','{date_end}')"
        logger.log(query, 'INFO', True)
        report.set_db('postgres', 'tgw')
        rows = None
        try:
            rows = report.get_db().call_select(query)
        except BaseException as exp:
            logger.log(exp, 'INFO', args.verbose)
            break
        if rows:
            (date_start, date_end, in_select, in_all, in_insert,
             in_update) = rows[0]
            res_data['select'] += in_select
            res_data['all'] += in_all
            res_data['insert'] += in_insert
            res_data['update'] += in_update
            logger.log(
                f"{date_start} -- {date_end}: "
예제 #3
0
logger = Logger(logfile)
#logger.set_param('covid_maker.log')
#conn = args.connection

# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    args.date_start, args.date_end = ('2021-05-01', '2021-06-17')
    args.output = './report'

    t0 = timer.get_time()
    report = DIT_report(args.date_start, args.date_end, args.config,
                        args.output, args.contract)
    query = f"SELECT day,sender,template_id,count(1) AS msg FROM new_message WHERE sender='7757' AND " \
            f"day>='{args.date_start}' AND day<'{args.date_end}' AND status!=6  " \
            f"GROUP BY day,sender,template_id ORDER BY day,sender,msg"
    print(query)
    query = "select day,receiver,count(1) as msgs from new_message WHERE sender='7757' AND day>='2021-06-05' AND day<'2021-06-17' AND status!=6 AND template_id=480 group by day,receiver order by day,receiver,msgs;"
    report.tunnels.start()
    report.set_db('postgres', 'mapi')
    rows = report.get_db().call_select(query)

    print(rows[0])
    filepath = f"{report.get_output_dir()}/7757_tmpl_report_num.csv"
    print(filepath)
    file = File(filepath, 'csv')

    file.csv_save(['receiver', 'count of msgs'], rows)

    t2 = timer.time_execute(t0)
    logger.log(f"Finished. Time execute: {t2}", 'INFO', True)
예제 #4
0
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    t0 = time.time()
    bar = IncrementalBar('Countdown', max=3)
    report = DIT_report('2021-04-01', '2021-04-20', 'config/config_ditrep.xml',
                        args.output)

    print(report.date_start, report.date_end)
    query = 'SELECT phone FROM proxy_user_ban'
    # config = report.get_config_db_data('tmpl',)
    # print(config)
    # config = report.get_connection_data('tmpl')
    # config['query'] = query
    # print(config)
    # phones = report.call_select(**config)
    report.set_db(prefix='tmpl')
    phones = report.get_db().call_select(query)
    print(len(phones))
    bar.next()
    phones_in_ban = set(phone[0] for phone in phones)
    '''

    query = f"SELECT da FROM mt WHERE submitted>='2021-04-16' and submitted<'2021-04-17' and conn like 'tele2%' and err_submit in (8,10)"
    print(query)
    report.set_db(prefix='tgw')
    phones = report.get_db().call_select(query)
    bar.next()
    phones_in_t2 = set(phone[0] for phone in phones)
    unban = []
    for phone in phones_in_ban:
        if phone in phones_in_t2:
예제 #5
0
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    args.config = 'config/config_ditrep.xml'
    report = DIT_report(args.date_start,args.date_end,args.config,args.output)


    date_start = '2021-04-01'
    date_end = '2021-04-12'
    day='2021-04-19'
    conn='mts'
    file_log=f'/opt/apps/tgw_mobilizer/conn-{conn}/logs/sads_smpp.log.{day}'
    err_dlvr_code='10100'
    query = f"SELECT created,updated,oa,da,resource_id FROM mt_result WHERE err_dlvr_code='{err_dlvr_code}' AND conn='{conn}' AND day='{day}' AND created=updated ORDER BY day,created"
    report.get_db().set_typedb('click')
    report.set_db('click','click')
    #print('c:', report.get_db().get_typedb(),report.get_db().get_config())

    rows = report.get_db().call_select(query)
    resource_ids = [item[4] for item in rows]
    resource_ids = tuple(resource_ids)
    print(len(resource_ids))
    report.set_db('postgres','tgw')
    list_id = str(resource_ids)
    list_id = list_id.replace("'",'"')


    #with open(f'report/unstat_{conn}_{day}.csv', 'w') as fout:
    with open(f'report/unstat_{conn}_{day}.csv', 'w') as fout:
        for id in resource_ids:
            query = f"SELECT * from get_msg_ids('{id}')"