

@classmethod
def extract_document(cls, obj):
    'Extract indexable attributes from an add-on.'
    attrs = ('id', 'average_daily_users', 'bayesian_rating', 'created', 'default_locale', 'guid', 'hotness', 'is_disabled', 'is_listed', 'last_updated', 'public_stats', 'slug', 'status', 'type', 'weekly_downloads')
    data = {attr: getattr(obj, attr) for attr in attrs}
    if (obj.type == amo.ADDON_PERSONA):
        try:
            data['boost'] = (obj.persona.popularity ** 0.2)
            data['has_theme_rereview'] = obj.persona.rereviewqueuetheme_set.exists()
            data['weekly_downloads'] = obj.persona.popularity
        except ObjectDoesNotExist:
            pass
    else:
        data['boost'] = (obj.average_daily_users ** 0.2)
        data['has_theme_rereview'] = None
    data['app'] = [app.id for app in obj.compatible_apps.keys()]
    data['appversion'] = {
        
    }
    for (app, appver) in obj.compatible_apps.items():
        if cls:
            (min_, max_) = (appver.min.version_int, appver.max.version_int)
        else:
            (min_, max_) = (0, version_int('9999'))
        data['appversion'][app.id] = dict(min=min_, max=max_)
    data['authors'] = [a.name for a in obj.listed_authors]
    if ((obj.status == amo.STATUS_PUBLIC) and ('boost' in data)):
        data['boost'] = (max(data['boost'], 1) * 4)
    data['category'] = getattr(obj, 'category_ids', [])
    if obj.current_version:
        data['current_version'] = {
            'id': obj.current_version.pk,
            'files': [{
                'id': file_.id,
                'created': file_.created,
                'filename': file_.filename,
                'hash': file_.hash,
                'platform': file_.platform,
                'size': file_.size,
                'status': file_.status,
            } for file_ in obj.current_version.all_files],
            'reviewed': obj.current_version.reviewed,
            'version': obj.current_version.version,
        }
        data['has_version'] = True
        data['platforms'] = [p.id for p in obj.current_version.supported_platforms]
    else:
        data['has_version'] = None
    data['tags'] = getattr(obj, 'tag_list', [])
    for field in ('description', 'name', 'summary'):
        data.update(cls.extract_field_raw_translations(obj, field))
        data.update(cls.extract_field_search_translations(obj, field))
        data.update(cls.extract_field_analyzed_translations(obj, field))
    for field in ('homepage', 'support_email', 'support_url'):
        data.update(cls.extract_field_raw_translations(obj, field))
    data['name_sort'] = unicode(obj.name).lower()
    return data

dataset/ETHPy150Open mozilla/addons-server/src/olympia/addons/indexers.py AddonIndexer.extract_document/VarMisuse@210/339 `appver`->`cls`