<commit_before># -*- coding: utf-8 -*-
from couchdb import Database, http
from couchdb.design import ViewDefinition


tenders_map = u"""
function(doc) {
    if(doc.status.indexOf('draft') !== -1) {return;};
    if(doc.status.indexOf('terminated') !== -1) {return;};
    if(('doc_type' in doc) && (doc.doc_type !== 'Tender')) {return;};
    if(doc.title.search("ТЕСТУВАННЯ") !== -1) {return;};
    if(doc.title_ru.search("ТЕСТИРОВАНИЕ") !== -1) {return;};
    if(doc.title_en.search("TESTING") !== -1) {return;};
    if(('mode' in doc) && (doc.mode === 'test')) {return;};
    emit(doc._id, null);
}
"""


tenders_all = ViewDefinition(
    'tenders', 'all',
    map_fun=tenders_map
)


tenders_date_modified = ViewDefinition(
    'tenders', 'by_dateModified',
    map_fun=u"""function(doc) {emit(doc.id, doc.dateModified);}"""
)

tenders_date_modified_for_package = ViewDefinition(
    'tenders', 'by_dateModified_pack',
    map_fun=u"""function(doc) {emit(doc.dateModified, doc.id);}"""
)


def get_or_create(url, name):
    resource = http.Resource(url, session=None)
    try:
        return resource.head(name)<commit_msg>Typo fix in couchdb views<commit_after># -*- coding: utf-8 -*-
from couchdb import Database, http
from couchdb.design import ViewDefinition


tenders_map = u"""
function(doc) {
    if(doc.status.indexOf('draft') !== -1) {return;};
    if(doc.status.indexOf('terminated') !== -1) {return;};
    if((doc.doc_type || "" ) !== 'Tender') {return;}
    if((doc.title || "" ).search("ТЕСТУВАННЯ") !== -1) {return;}
    if((doc.title_ru || "" ).search("ТЕСТИРОВАНИЕ") !== -1) {return;}
    if((doc.title_en || "" ).search("TESTING") !== -1) {return;}
    if((doc.mode || "") === 'test') {return;};
    emit(doc._id, null);
}
"""


tenders_all = ViewDefinition(
    'tenders', 'all',
    map_fun=tenders_map
)


tenders_date_modified = ViewDefinition(
    'tenders', 'by_dateModified',
    map_fun=u"""function(doc) {emit(doc.id, doc.dateModified);}"""
)

tenders_date_modified_for_package = ViewDefinition(
    'tenders', 'by_dateModified_pack',
    map_fun=u"""function(doc) {emit(doc.dateModified, doc.id);}"""
)


def get_or_create(url, name):
    resource = http.Resource(url, session=None)
    try:
        return resource.head(name)
{'fraction_non_alphanumeric': 0.20496894409937888, 'fraction_numerical': 0.005323868677905945, 'mean_word_length': 4.3818615751789975, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5986461', 'n_tokens_mistral': 844, 'n_tokens_neox': 830, 'n_words': 144}