def extract_update_count(update, all_apps=None):
    doc = {'addon': update.addon_id,
           'date': update.date,
           'count': update.count,
           'id': update.id,
           '_id': '{0}-{1}'.format(update.addon_id, update.date),
           'versions': es_dict(update.versions),
           'os': [],
           'locales': [],
           'apps': [],
           'status': []}

    # Only count platforms we know about.
    if update.oses:
        os = collections.defaultdict(int)
        for key, count in update.oses.items():
            platform = None

            if unicode(key).lower() in amo.PLATFORM_DICT:
                platform = amo.PLATFORM_DICT[unicode(key).lower()]
            elif amo.PLATFORMS in key:
                platform = amo.PLATFORMS[key]

            if platform is not None:
                os[platform.name] += count
                doc['os'] = es_dict((unicode(k), v) for k, v in os.items())

    # Case-normalize locales.
    if update.locales:
        locales = collections.defaultdict(int)
        for locale, count in update.locales.items():
            try:
                locales[locale.lower()] += int(count)
            except ValueError:
                pass
        doc['locales'] = es_dict(locales)

    # Only count app/version combos we know about.
    if update.applications:
        apps = collections.defaultdict(dict)
        for guid, version_counts in update.applications.items():
            if guid not in amo.APP_GUIDS:
                continue
            app = amo.APP_GUIDS[guid]
            for version, count in version_counts.items():
                try:
                    apps[app.guid][version] = int(count)
                except ValueError:
                    pass
        doc['apps'] = dict((app, es_dict(vals)) for app, vals in apps.items())

    if update.statuses:
        doc['status'] = es_dict((k, v) for k, v in update.statuses.items()
                                if k != 'null')
    return doc
dataset/ETHPy150Open mozilla/addons-server/src/olympia/stats/search.py/extract_update_count/swapped operands of `in`