<commit_before>from ...logging import get_logger
from ...errors import *
from ...browser import *
from ...computation import *
from ...statutils import calculators_for_aggregates, available_calculators
from cubes import statutils
from .mapper import MongoCollectionMapper
from .datesupport import DateSupport
from .functions import get_aggregate_function, available_aggregate_functions
from .util import to_json_safe, collapse_record

import collections
import copy
import pymongo
import bson
import re

from dateutil.relativedelta import relativedelta
from datetime import datetime
from itertools import groupby
from functools import partial
import pytz


tz_utc = pytz.timezone('UTC')


SO_FAR_DIMENSION_REGEX = re.compile(r"^.+_sf$", re.IGNORECASE)

def is_date_dimension(dim):
    if isinstance(dim, basestring):
        return 'date' in dim.lower()
    elif hasattr(dim, 'info'):
        return (not not dim.info.get('is_date'))
    elif hasattr(dim, 'name'):
        return 'date' in dim.name
    else:
        return False

class Mongo2Browser(AggregationBrowser):<commit_msg>mongo2 backend properly identifies time dimensions<commit_after>from ...logging import get_logger
from ...errors import *
from ...browser import *
from ...computation import *
from ...statutils import calculators_for_aggregates, available_calculators
from cubes import statutils
from .mapper import MongoCollectionMapper
from .datesupport import DateSupport
from .functions import get_aggregate_function, available_aggregate_functions
from .util import to_json_safe, collapse_record

import collections
import copy
import pymongo
import bson
import re

from dateutil.relativedelta import relativedelta
from datetime import datetime
from itertools import groupby
from functools import partial
import pytz


tz_utc = pytz.timezone('UTC')


SO_FAR_DIMENSION_REGEX = re.compile(r"^.+_sf$", re.IGNORECASE)

def is_date_dimension(dim):
    if hasattr(dim, 'role'):
        return (dim.role == 'time')
    elif hasattr(dim, 'info'):
        return (not not dim.info.get('is_date'))
    else:
        return False

class Mongo2Browser(AggregationBrowser):
{'fraction_non_alphanumeric': 0.0784037558685446, 'fraction_numerical': 0.0014084507042253522, 'mean_word_length': 4.854395604395604, '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': '5809280', 'n_tokens_mistral': 640, 'n_tokens_neox': 622, 'n_words': 198}