Ejemplo n.º 1
0
def sample_folder(multiplier):
    from repoze.folder import Folder
    from zope.interface import alsoProvides
    from osi.interfaces import IMetricsMonthFolder
    f = Folder()
    alsoProvides(f, IMetricsMonthFolder)
    f.contenttypes = sample_content_types(multiplier)
    username = u'marty' if multiplier % 2 == 0 else u'mcfly'
    f.profiles = sample_profiles(username, multiplier)
    commid, commtitle = (('delorean', 'Delorean') if multiplier % 2 == 0
                         else ('flux', 'Capacitor'))
    f.communities = sample_communities(commid, commtitle, multiplier)
    f.users = sample_users(multiplier)
    return f
Ejemplo n.º 2
0
def generate_metrics(root, year, month):
    contenttype = metrics.collect_contenttype_metrics(root, year, month)
    profiles = metrics.collect_profile_metrics(root, year, month)
    users = metrics.collect_user_metrics(root, year, month)
    communities = metrics.collect_community_metrics(root, year, month)

    metrics_folder = find_or_create_metrics_container(root)

    year_folder = metrics_folder.get(str(year), None)
    if year_folder is None:
        year_folder = Folder()
        alsoProvides(year_folder, IMetricsYearFolder)
        metrics_folder[str(year)] = year_folder

    month_folder = year_folder.get(month_string(month), None)
    if month_folder is None:
        month_folder = Folder()
        alsoProvides(month_folder, IMetricsMonthFolder)
        year_folder[month_string(month)] = month_folder

    month_folder.contenttypes = OOBTree(contenttype)
    month_folder.profiles = OOBTree(profiles)
    month_folder.users = OOBTree(users)
    month_folder.communities = OOBTree(communities)