<commit_before>""" Query modules mapping functions to their query strings
structured:

module_name { query_string: function_for_query }

"""
import sys
import os
import math
import datetime
import logging
sys.path.append("%s" % os.getcwd())
sys.path.append("%s/../../CFC_WebApp/" % os.getcwd())
logging.basicConfig(format='%(asctime)s:%(levelname)s:%(message)s', level=logging.DEBUG)

from main.K_medoid_2 import kmedoids, user_route_data
from main.route_matching import update_user_routeDistanceMatrix, update_user_routeClusters

from get_database import get_section_db, get_trip_db, get_routeCluster_db, get_alternatives_db
import trip
import random
from uuid import UUID

from main.get_database import get_routeCluster_db, get_section_db
# 0763de67-f61e-3f5d-90e7-518e69793954
# 0763de67-f61e-3f5d-90e7-518e69793954_20150421T230304-0700_0
# helper for getCanonicalTrips
def get_clusters_info(uid):
        c_db = get_routeCluster_db()
        s_db = get_section_db()
        clusterJson = c_db.find_one({"clusters":{"$exists":True}, "user": uid})
        if clusterJson is None:
            return []
        c_info = []
        x = clusterJson["clusters"].values() 
        for col in x:
                first = True
                y = [[] for _ in range(5)]
                for cluster in col:
                        if first:
                            rt = info
                            first = False
                        info = s_db.find_one({"_id":cluster})
                        appendIfPresent(y[0], info, "section_start_datetime")
                        appendIfPresent(y[1], info, "section_end_datetime")
                        appendIfPresent(y[2], info, "section_start_point")
                        appendIfPresent(y[3], info, "section_end_point")
                        appendIfPresent(y[4], info, "confirmed_mode")
                c_info.append(y, rt)
        return c_info

def appendIfPresent(list,element,key):
    if element is not None and key in element:<commit_msg>Stupid ordering mistake<commit_after>""" Query modules mapping functions to their query strings
structured:

module_name { query_string: function_for_query }

"""
import sys
import os
import math
import datetime
import logging
sys.path.append("%s" % os.getcwd())
sys.path.append("%s/../../CFC_WebApp/" % os.getcwd())
logging.basicConfig(format='%(asctime)s:%(levelname)s:%(message)s', level=logging.DEBUG)

from main.K_medoid_2 import kmedoids, user_route_data
from main.route_matching import update_user_routeDistanceMatrix, update_user_routeClusters

from get_database import get_section_db, get_trip_db, get_routeCluster_db, get_alternatives_db
import trip
import random
from uuid import UUID

from main.get_database import get_routeCluster_db, get_section_db
# 0763de67-f61e-3f5d-90e7-518e69793954
# 0763de67-f61e-3f5d-90e7-518e69793954_20150421T230304-0700_0
# helper for getCanonicalTrips
def get_clusters_info(uid):
        c_db = get_routeCluster_db()
        s_db = get_section_db()
        clusterJson = c_db.find_one({"clusters":{"$exists":True}, "user": uid})
        if clusterJson is None:
            return []
        c_info = []
        x = clusterJson["clusters"].values() 
        for col in x:
                first = True
                y = [[] for _ in range(5)]
                for cluster in col:
                        info = s_db.find_one({"_id":cluster})
                        if first:
                            rt = info
                            first = False
                        appendIfPresent(y[0], info, "section_start_datetime")
                        appendIfPresent(y[1], info, "section_end_datetime")
                        appendIfPresent(y[2], info, "section_start_point")
                        appendIfPresent(y[3], info, "section_end_point")
                        appendIfPresent(y[4], info, "confirmed_mode")
                c_info.append(y, rt)
        return c_info

def appendIfPresent(list,element,key):
    if element is not None and key in element:
{'fraction_non_alphanumeric': 0.09850746268656717, 'fraction_numerical': 0.03681592039800995, 'mean_word_length': 2.567879325643301, 'pattern_counts': {'":': 8, '<': 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': '6030244', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1211, 'n_words': 269}