def refresh_products_from_tiids(profile_id, tiids, analytics_credentials={}, source="webapp"):
    # assume the profile is the same one as the first product
    if not profile_id:
        temp_profile = Product.query.get(tiids[0])
        profile_id = temp_profile.profile_id
    
    from totalimpactwebapp.profile import Profile
    profile = Profile.query.get(profile_id)

    save_profile_refresh_status(profile, RefreshStatus.states["PROGRESS_BAR"])


    if not tiids:
        return None

    priority = "high"
    if source=="scheduled":
        priority = "low"

    products = Product.query.filter(Product.tiid.in_(tiids)).all()
    tiids_to_update = []  

    for product in products:
        try:
            tiid = product.tiid
            product.set_last_refresh_start()
            db.session.merge(product)
            tiids_to_update += [tiid]
        except __HOLE__:
            logger.debug(u"couldn't find tiid {tiid} so not refreshing its metrics".format(
                tiid=tiid))

    db.session.commit()

    start_product_update(profile_id, tiids_to_update, priority)
    return tiids
dataset/ETHPy150Open Impactstory/total-impact-webapp/totalimpactwebapp/product.py/refresh_products_from_tiids