Skip to content

Добавляет новые поля для clickHouse и парсинг параметров#1

Open
vusoltsev wants to merge 1 commit intoolegfedoseev:masterfrom
n1ru:master
Open

Добавляет новые поля для clickHouse и парсинг параметров#1
vusoltsev wants to merge 1 commit intoolegfedoseev:masterfrom
n1ru:master

Conversation

@vusoltsev
Copy link

No description provided.

if source == 'hits':
if ('ym:pv:date' in fields) and ('ym:pv:clientID' in fields):
engine = 'MergeTree(Date, intHash32(ClientID), (Date, intHash32(ClientID)), 8192)'
engine = 'MergeTree(date, intHash32(clientID), (date, intHash32(clientID)), 8192)'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему названия полей стали с маленькой буквы? Вроде в кликхаусе принято с большой

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Максим попросил сделать с маленькой, ему так проще сказал

else:
del splitted_text_filtered[i]
i -= 1
i += 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно площе и проще:

i = 1
while i < len(splitted_text_filtered):
    value = splitted_text_filtered[i].split('\t')
    
    if len(value[params_index]) == 0:
        del splitted_text_filtered[i]
        continue

    for field in ch_fields:
        params_json = clear_json(value[params_index])
        url = clear_json(value[url_index])
        if !is_json(params_json):
            splitted_text_filtered[i] += "\t"
            continue

        params = json.loads(params_json)
        splitted_text_filtered[i] += "\t"
        if len(params) > 0:
            if type(params) is list:
                params = params[0]
            data = parsing_params.get_data_from_params(prefix, params, field, url)
            splitted_text_filtered[i] += unicode(data)
    i += 1

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправил, сделал проще


action = params.keys()[0]

if field == prefix+'hitType':
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

На сколько я помню в питоне по pep8 операторы обособляются пробелами.
Тут и везде.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

исправил

return 'true' if offer_services.has_key('autoraiseX8') else 'false'

if field == prefix+'top':
return 'true' if offer_services.has_key('top') else 'false'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А зачем это всё? Зачем хардкодить имена сервисов? Мы разве не можем просто сохранить offer_services и уже в кликхаусе делать по ним выборки?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сначала сделал в offer_services, но требованию Максима пришлось для каждой услуги свое поле в таблице делать, говорит ему так удобнее будет

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants