def METHOD_NAME(project_id, user_id):
    available_integrations = integrations_manager.get_available_integrations(user_id=user_id)
    no_integration = not any(available_integrations.values())
    if no_integration:
        return []
    all_integrations = all(available_integrations.values())
    extra_query = ["sessions.project_id = %(project_id)s"]
    if not all_integrations:
        extra_query.append("provider IN %(providers)s")
    with pg_client.PostgresClient() as cur:
        query = cur.mogrify(f"""\
                SELECT assigned_sessions.*
                FROM public.assigned_sessions
                    INNER JOIN public.sessions USING (session_id)
                WHERE {" AND ".join(extra_query)};\