'Turn the given group information from DB into a dict
and add other characteristics like members and repositories.'

def _populate(self, trans, group):

    model = trans.app.model
    group_dict = group.to_dict(view='collection', value_mapper=self.__get_value_mapper(trans))
    group_members = []
    group_repos = []
    total_downloads = 0
    for uga in group.users:
        user = trans.sa_session.query(model.User).filter((model.User.table.c.id == uga.user_id)).one()
        user_repos_count = 0
        for repo in trans.sa_session.query(model.Repository).filter((model.Repository.table.c.user_id == uga.user_id)).join(model.RepositoryMetadata.table).join(model.User.table).outerjoin(model.RepositoryCategoryAssociation.table).outerjoin(model.Category.table):
            categories = []
            for rca in repo.categories:
                cat_dict = dict(name=rca.category.name, id=trans.app.security.encode_id(rca.category.id))
                categories.append(cat_dict)
            time_repo_created_full = repo.create_time.strftime('%Y-%m-%d    %I:%M    %p')
            time_repo_updated_full = repo.update_time.strftime('%Y-%m-%d    %I:%M    %p')
            time_repo_created = pretty_print_time_interval(repo.create_time, True)
            time_repo_updated = pretty_print_time_interval(repo.update_time, True)
            approved = ''
            ratings = []
            for review in repo.reviews:
                if review.rating:
                    ratings.append(review.rating)
                if (review.approved == 'yes'):
                    approved = 'yes'
            ratings_mean = (str((float(sum(ratings)) / len(ratings))) if (len(ratings) > 0) else '')
            total_downloads += repo.times_downloaded
            group_repos.append({'name': repo.name, 'times_downloaded': repo.times_downloaded, 'owner': repo.user.username, 'time_created_full': time_repo_created_full, 'time_created': time_repo_created, 'time_updated_full': time_repo_updated_full, 'time_updated': time_repo_updated, 'description': repo.description, 'approved': approved, 'ratings_mean': ratings_mean, 'categories': categories})
            user_repos_count += 1
        encoded_user_id = trans.app.security.encode_id(repo.user.id)
        user_repos_url = web.url_for(controller='repository', action='browse_repositories_by_user', user_id=encoded_user_id)
        time_created = pretty_print_time_interval(user.create_time, True)
        member_dict = {'id': encoded_user_id, 'username': user.username, 'user_repos_url': user_repos_url, 'user_repos_count': user_repos_count, 'user_tools_count': 'unknown', 'time_created': time_created}
        group_members.append(member_dict)
    group_dict['members'] = group_members
    group_dict['total_members'] = len(group_members)
    group_dict['repositories'] = group_repos
    group_dict['total_repos'] = len(group_repos)
    group_dict['total_downloads'] = total_downloads
    return group_dict
