def main(): load_dotenv(dotenv_path='.env') elastic_search_host = os.getenv("ELASTIC_SEARCH_HOST") es = Elasticsearch([elastic_search_host], use_ssl=False) client = RecombeeClient(os.getenv("RECOMBEE_DATABASE_ID"), os.getenv("RECOMBEE_PRIVATE_TOKEN")) num_recipes = es.count(index=os.getenv("ELASTIC_SEARCH_INDEX"), body={"query": { "match_all": {} }})["count"] recipes = scan(client=es, index=os.getenv("ELASTIC_SEARCH_INDEX"), query={"query": { "match_all": {} }}, size=BATCH_SIZE, scroll='1ms') requests = [ SetItemValues(recipe['_id'], { 'title': recipe['_source']['title'], 'ingredients': recipe['_source']['ingredients'], 'link': recipe['_source']['link'], 'image': recipe['_source']['image'], 'tags': recipe['_source']['tags'], 'total_time': recipe['_source']['total_time'], 'rating': recipe['_source']['rating'], 'time_acquired': recipe['_source']['time_acquired'], }, cascade_create=True) for recipe in recipes ] client.send(Batch(requests))
class RecombeeTest( unittest.TestCase ): def __init__(self, *args, **kwargs): super(RecombeeTest, self).__init__(*args, **kwargs) self.client = RecombeeClient('client-test', 'jGGQ6ZKa8rQ1zTAyxTc0EMn55YPF7FJLUtaMLhbsGxmvwxgTwXYqmUk5xVZFw98L') def setUp(self): self.client.send(ResetDatabase()) batch = Batch([ AddItem('entity_id'), AddUser('entity_id'), AddSeries('entity_id'), AddGroup('entity_id'), InsertToGroup('entity_id', 'item', 'entity_id'), InsertToSeries('entity_id', 'item', 'entity_id', 1), AddItemProperty('int_property', 'int'), AddItemProperty('str_property', 'string'), SetItemValues('entity_id', {'int_property': 42, 'str_property': 'hello'}), AddUserProperty('int_property', 'int'), AddUserProperty('str_property', 'string'), SetUserValues('entity_id', {'int_property': 42, 'str_property': 'hello'}) ]) self.client.send(batch)
def offer(request, offer_id): offer = Product.objects.all().filter(id=offer_id, is_offer=True) reviews = ProductsReview.objects.all().filter(product=offer_id) context = { 'offer': offer, 'reviews': reviews, } client = RecombeeClient( 'e-market-dev', 'S1HpoVU0JuxtjU9ewtvSnAUQh4qgKHTjr2DFbQ30LoADU2S27OsleTi1C23TNVEm') current_user = request.user r = AddDetailView(current_user.id, offer_id, cascade_create=True) client.send(r) recommended = client.send( RecommendItemsToItem(offer_id, current_user.id, 3)) related = recommended['recomms'] related_products_id = [] for r in related: related_products_id.append(r['id']) related_products = [] for id in related_products_id: prod = Product.objects.all().filter(id=id) related_products.append(prod) context['suggested_offers'] = related_products return render(request, 'listings/offer.html', context)
def listing(request, product_id): if (request.method == 'POST'): if (request.POST['star1'] == 'active'): stars = 1 elif (request.POST['star2'] == 'active'): stars = 2 elif (request.POST['star3'] == 'active'): stars = 3 elif (request.POST['star4'] == 'active'): stars = 4 elif (request.POST['star5'] == 'active'): stars = 5 #if user didn't make any rating else: stars = 0 review = request.POST['review'] # product = Product.objects.all().filter(id=product_id) product_review = ProductsReview.objects.create(product_id=product_id, user_id=request.user.id, review=review, rating=stars) submit_product_review(product_id) product = Product.objects.all().filter(id=product_id) reviews = ProductsReview.objects.all().filter(product=product_id) client = RecombeeClient( 'e-market-dev', 'S1HpoVU0JuxtjU9ewtvSnAUQh4qgKHTjr2DFbQ30LoADU2S27OsleTi1C23TNVEm') current_user = request.user if (current_user.is_authenticated): current_user_id = current_user.id else: current_user_id = 0 r = AddDetailView(current_user_id, product_id, cascade_create=True) client.send(r) recommended = client.send( RecommendItemsToItem(product_id, current_user_id, 3)) related = recommended['recomms'] related_products_id = [] for r in related: related_products_id.append(r['id']) related_products = [] for id in related_products_id: prod = Product.objects.all().filter(id=id) related_products.append(prod) # for prod in recommended: # print(f"prod {prod}") avg_rating = get_avg_rating(product_id) context = { 'product': product, 'reviews': reviews, 'avg_rating': round(avg_rating, 1), 'related_products': related_products, } return render(request, 'listings/listing.html', context)
def get(self, user_id): _ = get_token_info() client = RecombeeClient( 'globalhack', 'QluRxG1ZkI3kRKvukeXpscV4kRcTxIPAIYbxVjlD14FJlhS0rLdVYVxv25NNeBYC') try: # get the recommendation response = client.send(RecommendItemsToUser(user_id, 5)) return make_response(jsonify(response)) except Exception: abort(status.HTTP_500_INTERNAL_SERVER_ERROR)
def post(self, user_id, service_id): _ = get_token_info() client = RecombeeClient( 'globalhack', 'QluRxG1ZkI3kRKvukeXpscV4kRcTxIPAIYbxVjlD14FJlhS0rLdVYVxv25NNeBYC') request = AddPurchase(user_id, service_id, cascade_create=True) purchase_requests = [request] try: # Send the data to Recombee, use Batch for faster processing of larger data response = client.send(Batch(purchase_requests)) return make_response(jsonify(response)) except Exception: abort(status.HTTP_500_INTERNAL_SERVER_ERROR)
def __init__(self, *args, **kwargs): super(RecombeeTest, self).__init__(*args, **kwargs) db_id = os.environ.get('DB_ID') if db_id is None: raise MissingEnvironmentVariable('DB_ID env var must be specified') token = os.environ.get('PRIVATE_TOKEN') if token is None: raise MissingEnvironmentVariable( 'PRIVATE_TOKEN env var must be specified') self.client = RecombeeClient(db_id, token, region=Region.EU_WEST)
def update_item(request): #data mining setup client = RecombeeClient( 'e-market-dev', 'S1HpoVU0JuxtjU9ewtvSnAUQh4qgKHTjr2DFbQ30LoADU2S27OsleTi1C23TNVEm') data = json.loads(request.body) productId = data['productId'] action = data['action'] current_user = request.user product = Product.objects.get(id=productId) product.sold = product.sold + 1 product.save() order, created = Order.objects.get_or_create(user=current_user, complete=False) orderItem, created = OrderItem.objects.get_or_create(order=order, product=product) if (action == 'add'): print(f"usre ID: {current_user.id}, product ID: {product.id}") r = AddPurchase(current_user.id, product.id, timestamp=time.time(), cascade_create=True) client.send(r) orderItem.quantity = (orderItem.quantity + 1) product.quantity = (product.quantity - 1) if (product.quantity <= 0): product.in_stock = False product.save() else: product.quantity = product.quantity - 1 product.save() elif (action == 'remove'): orderItem.quantity = (orderItem.quantity - 1) product.quantity = (product.quantity + 1) product.save() orderItem.save() if (orderItem.quantity <= 0): orderItem.delete() print(f'Action: {action}, productId: {productId}') return JsonResponse('Item was added', safe=False)
def init_crawler(num=0, init=0): es = connect_to_es() client = RecombeeClient(os.getenv("RECOMBEE_DATABASE_ID"), os.getenv("RECOMBEE_PRIVATE_TOKEN")) #Create a crawling process for all crawlers to make use of Scrapy's concurrency process = CrawlerProcess(settings=get_project_settings()) for host, site in URLS.items(): #Create an instance of each site's crawler obj = site(math.floor(num / len(URLS.items())), init) #Instruct the process to crawl each individual site, but only start the actual crawling process once they're all ready obj.crawl(es, client, process) process.start() process.stop()
def push_zion(database, token, prod_list, user, timestamp=False): items = get_global_dic(prod_list, user) print(items) client = RecombeeClient(database, token) if timestamp: requests = [] for item in items: r = AddPurchase(item['user_id'], item['item_id'], timestamp=item['timestamp'], cascade_create=True) client.send(r) requests = [] for item in items: r = AddDetailView(item['user_id'], item['item_id'], timestamp=item['timestamp'], cascade_create=True) requests.append(r) br = Batch(requests) client.send(br) else: requests = [] for item in items: r = AddPurchase(item['user_id'], item['item_id'], cascade_create=True) client.send(r) requests = [] for item in items: r = AddDetailView(item['user_id'], item['item_id'], cascade_create=True) requests.append(r) br = Batch(requests) client.send(br) print('Done')
class RecombeeTest(unittest.TestCase): def __init__(self, *args, **kwargs): super(RecombeeTest, self).__init__(*args, **kwargs) db_id = os.environ.get('DB_ID') if db_id is None: raise MissingEnvironmentVariable('DB_ID env var must be specified') token = os.environ.get('PRIVATE_TOKEN') if token is None: raise MissingEnvironmentVariable( 'PRIVATE_TOKEN env var must be specified') self.client = RecombeeClient(db_id, token, region=Region.EU_WEST) def setUp(self): self.client.send(ResetDatabase()) while True: try: self.client.send(ListItems()) except ResponseException as e: # Wait until DB is erased continue break batch = Batch([ AddItem('entity_id'), AddUser('entity_id'), AddSeries('entity_id'), AddGroup('entity_id'), InsertToGroup('entity_id', 'item', 'entity_id'), InsertToSeries('entity_id', 'item', 'entity_id', 1), AddItemProperty('int_property', 'int'), AddItemProperty('str_property', 'string'), SetItemValues('entity_id', { 'int_property': 42, 'str_property': 'hello' }), AddUserProperty('int_property', 'int'), AddUserProperty('str_property', 'string'), SetUserValues('entity_id', { 'int_property': 42, 'str_property': 'hello' }) ]) self.client.send(batch)
def index(request): categories = Category.objects.all() product = Product.objects.all() current_user = request.user client = RecombeeClient( 'e-market-dev', 'S1HpoVU0JuxtjU9ewtvSnAUQh4qgKHTjr2DFbQ30LoADU2S27OsleTi1C23TNVEm') prods = Product.objects.order_by('-sold')[:6] best_sellers = sorted(prods, key=operator.attrgetter('sold'), reverse=True) print(f"best_sellers: {best_sellers}") context = { 'categories': categories, 'best_sellers': best_sellers, } # recomender # if (request.user.is_authenticated): # print("auth") if (not request.user.is_authenticated): current_user_id = 0 else: current_user_id = current_user.id recommended = client.send( RecommendItemsToUser(current_user_id, 5, cascade_create=True)) # print(recommended) client = RecombeeClient( 'e-market-dev', 'S1HpoVU0JuxtjU9ewtvSnAUQh4qgKHTjr2DFbQ30LoADU2S27OsleTi1C23TNVEm') current_user = request.user recommended = client.send(RecommendItemsToUser(current_user_id, 3)) print(f"Related products: {recommended}") suggested = recommended['recomms'] suggested_products_id = [] for r in suggested: suggested_products_id.append(r['id']) suggested_products = [] for id in suggested_products_id: prod = Product.objects.all().filter(id=id) suggested_products.append(prod) print(f"related: {suggested_products}") context['suggested_products'] = suggested_products return render(request, 'pages/index.html', context)
from recombee_api_client.api_client import RecombeeClient from recombee_api_client.api_requests import * import csv client = RecombeeClient('wt-proj', 'gVEMJ5zdYOleXwlX4MyCtExwaa8MgAFgejz0W7TPa8kB1Qebtp1t0OvESDDdwrmO') purchases = [] with open('purchaseRecord.csv') as csvfile: csvreader = csv.reader(csvfile) for row in csvreader: user_id = row[0] item_id = row[1] r = AddPurchase(user_id, item_id, cascade_create = True) purchases.append(r) br = Batch(purchases) print(br) client.send(br) recommended = client.send(UserBasedRecommendation('0', 5)) print(recommended)
def pred_prod(database, token, USER, NUMBER): client = RecombeeClient(database, token) recommended = client.send(RecommendItemsToUser(USER, 5)) print(recommended)
from django.http import HttpResponseRedirect, HttpResponse from django.contrib.auth import authenticate from django.urls import reverse from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User from .models import * from recombee_api_client.api_client import RecombeeClient from recombee_api_client.exceptions import APIException from recombee_api_client.api_requests import * from django.views.generic.base import TemplateView from django.views.generic.list import ListView from django.views.generic.detail import DetailView from django.views.generic.edit import DeleteView client = RecombeeClient( 'tvseries', 'IG1t5vSWYgpJvClpbJZUn29oqnCu6QnIHoJdm9u5dRLom47i0WrpWrNKcZ9om21x') def homepage(request): return render(request, './show/index.html') def login(request): if request.user.is_authenticated: redirect_url = '/profile/' + str(request.user.id) return HttpResponseRedirect(redirect_url) else: if request.method == 'POST': username = request.POST.get('username', '') password = request.POST.get('password', '')
#run this file one time to seed DB at Recombee.com from recombee_api_client.api_client import RecombeeClient from recombee_api_client.api_requests import * import json import os # to access OS environment variables client = RecombeeClient(os.environ['DB_NAME'], os.environ['SECRET_TOKEN']) with open('static/dataset/movie_user_ratings.json') as fdata: interactions = json.loads(fdata.read()) requests = [] #interate through all interactions and create object for each interaction for interaction in interactions: r = AddRating(interaction['userid'], interaction['imdbid'], interaction['rating'], cascade_create=True) #making a list of interactions requests.append(r) br = Batch(requests) try: # Send the data to Recombee, use Batch for faster processing of larger data print('Send ratings') client.send(br) except APIException as e: print(e)
from recombee_api_client.api_requests import RecommendItemsToItem, AddRating, RecommendItemsToUser, SetViewPortion from recombee_api_client.api_client import RecombeeClient client = RecombeeClient( 'moodsic-dev', 'Pb4MhOK6751HmdEGmvISdFJqXjLDWEtVkyb2AIY4Cn1EL3vQWy9V0B236OGEj8iy') class Recommendation: # this is caught from the front boosters = { "empty": None, "booster_for_happy": "if a then b", "booster_for_sad": "if b then a", } filters = { "empty": None, "preference_filter1": "filter by some value", "preference_filter2": "filter by some value", } scenarios = {"main": "main_music"} def __init__(self, recom_type, user_id=0, item_id=0, scenario="main", r_filter="empty", booster="empty", number_of_items=10):
from recombee_api_client.api_client import RecombeeClient from recombee_api_client.api_requests import AddItemProperty, SetItemValues, AddPurchase from recombee_api_client.api_requests import ItemBasedRecommendation, Batch, ResetDatabase import random import csv PROBABILITY_PURCHASED = 0.1 client = RecombeeClient('wt-proj', 'gVEMJ5zdYOleXwlX4MyCtExwaa8MgAFgejz0W7TPa8kB1Qebtp1t0OvESDDdwrmO') #Clear the entire database client.send(ResetDatabase()) # We will use courses as items # Courses have three properties # - domain (string) # - title (string) # - description (string) # Add properties of items client.send(AddItemProperty('domain', 'string')) client.send(AddItemProperty('title', 'string')) client.send(AddItemProperty('description', 'string')) # Prepare requests for setting a catalog of courses with open('courseCatalog.csv') as csvfile: csvreader = csv.reader(csvfile) for row in csvreader: requests = [SetItemValues( "course-%s" % row[0], #itemId
from recombee_api_client.api_client import RecombeeClient from recombee_api_client.api_requests import AddItemProperty, SetItemValues, AddPurchase from recombee_api_client.api_requests import ItemBasedRecommendation, Batch, ResetDatabase import random import csv PROBABILITY_PURCHASED = 0.1 client = RecombeeClient( 'wt-proj', 'gVEMJ5zdYOleXwlX4MyCtExwaa8MgAFgejz0W7TPa8kB1Qebtp1t0OvESDDdwrmO') #Clear the entire database client.send(ResetDatabase()) # We will use courses as items # Courses have three properties # - domain (string) # - title (string) # - description (string) # Add properties of items client.send(AddItemProperty('domain', 'string')) client.send(AddItemProperty('title', 'string')) client.send(AddItemProperty('description', 'string')) # Prepare requests for setting a catalog of courses with open('courseCatalog.csv') as csvfile: csvreader = csv.reader(csvfile) for row in csvreader:
from .models import Item from django.contrib.auth.models import User from django.contrib.auth.decorators import login_required from users.models import Profile from django.contrib import messages from django.views.generic import TemplateView, ListView from django.db.models import Q from .forms import SearchForm from django.core.paginator import Paginator from recombee_api_client.api_client import RecombeeClient from recombee_api_client.exceptions import APIException from recombee_api_client.api_requests import * # Create your views here. client = RecombeeClient( 'university-of-jordan-dev', 'sMGOTwMPzOPM3l6Tmxs8jXZ2WeCskPR9dnzKrdBczJHy1vdRFQs9HldcLPC8W63N') @login_required def recommend(request): user_profile = request.user.profile if user_profile.gender is None or user_profile.user_style is None or user_profile.user_class is None or user_profile.user_brands is None: messages.info( request, 'Please fill out some information for better cusotmized recommendations' ) return redirect('update_profile_initial') user_id = str( User.objects.filter(username=request.user.username).first().id)
def load_recombee(self): self.recombee_client = RecombeeClient(self.app.config['RECOMBEE_DB'], self.app.config['RECOMBEE_KEY'])
import csv import random from .models import * from recombee_api_client.api_client import RecombeeClient from recombee_api_client.exceptions import APIException from recombee_api_client.api_requests import * client = RecombeeClient( 'tvseries', 'IG1t5vSWYgpJvClpbJZUn29oqnCu6QnIHoJdm9u5dRLom47i0WrpWrNKcZ9om21x') requests = [] list_of_ratings = SeriesRating.objects.all() print(list_of_ratings) print(len(list_of_ratings)) for i in range(0, len(list_of_ratings)): name = list_of_ratings[i].user.id series = list_of_ratings[i].series.id rate = list_of_ratings[i].rating rate = (rate - 10) / 10 print(str(name) + ' ' + str(series) + ' ' + str(rate)) request = AddRating(name, series, rate, cascade_create=True) requests.append(request) print(len(requests)) print(requests) try: print('sending') client.send(Batch(requests)) print('Send') except APIException as e:
from recombee_api_client.api_client import RecombeeClient from recombee_api_client.api_requests import * client = RecombeeClient( 'sns', 'cqLZqZnboKlyVKS7EhhYYyM8BflGRDlizngZbljA3kp67tjd1FKfH3WaXLNSXl7F') print(client.send(GetItemValues('1'))) print(client.send(ListItemProperties())) recommended = client.send( UserBasedRecommendation('672', 5, filter="Animation" in 'genre')) print(recommended)
private_key_of_account = inp['key'] #private local Ethereum blockchain w3 = Web3(Web3.HTTPProvider("http://*****:*****@app.route('/Process', methods=['POST']) def Process(): """ Processes requests from GeniSys AI E-Commerce Magic Leap Application. """ if frequest.headers["Content-Type"] == "application/json": query = frequest.json #send action to smart contract nonce = w3.eth.getTransactionCount(msg_sender_address) transaction = myContract.functions.addDataCollected(
def __init__(self): print("recombee client was initiatlized") client = RecombeeClient(DB_NAME, API_KEY) self.recombee_client = client
def __init__(self, *args, **kwargs): super(RecombeeTest, self).__init__(*args, **kwargs) self.client = RecombeeClient( 'client-test', 'jGGQ6ZKa8rQ1zTAyxTc0EMn55YPF7FJLUtaMLhbsGxmvwxgTwXYqmUk5xVZFw98L')
import csv # from bookdb.models import * import random # from django.db import transaction from recombee_api_client.api_client import RecombeeClient from recombee_api_client.exceptions import APIException from recombee_api_client.api_requests import * client = RecombeeClient( 'wd-project', 'DDf4VljyLxNsbdLtWT1jueFbVsanOWCwbEW59cTpp1W3LB3JlpeT3jqZQ1k7S7sN') # @transaction.atomic # def main(): # with open('BX-CSV-Dump/BX-Users.csv', encoding='utf-8') as f: # reader = list(csv.reader(f, delimiter=';')) # # Skipping the headers # # next(reader) # print("Result =", len(reader)) # count = 0 # # transaction.set_autocommit(False) # with transaction.atomic(): # for row in reader[1:]: # count += 1 # # if User.objects.filter(id=int(row[0])).count() == 0: # user = User(id=int(row[0])) # user.username = str(user.id) # user.set_password('pass@123') # user.is_superuser = True # user.is_staff = True
from recombee_api_client.api_client import RecombeeClient from recombee_api_client.exceptions import APIException from recombee_api_client.api_requests import * client = RecombeeClient( 'moodsic-dev', 'Pb4MhOK6751HmdEGmvISdFJqXjLDWEtVkyb2AIY4Cn1EL3vQWy9V0B236OGEj8iy') #For reseting the database before changing the model client.send(ResetDatabase()) ######################################### # WARNING Recombee API creates some problems when you're trying to add an object # when it already exists, therefore if you want to build the model of the database, you have to # erase the whole database first, this is the best way yet # adendum: requst should be done in certain order # # PrimaryKey means that we will transfer PrimaryKeys from our server database to the recombee database as id-s ########################################## #DATA MODELS FOR USERS AND MUSIC client.send(AddUserProperty("username", "string")) client.send(AddUserProperty("usualMood", "string")) client.send(AddUserProperty("age", "int")) #this can be good enough for our needs client.send(AddItemProperty("mood", "string")) client.send(AddItemProperty("length", "double")) client.send(AddItemProperty("title", "string")) client.send(AddItemProperty("viewCount", "int"))
from recombee_api_client.api_client import RecombeeClient from recombee_api_client.api_requests import * import csv client = RecombeeClient( 'wt-proj', 'gVEMJ5zdYOleXwlX4MyCtExwaa8MgAFgejz0W7TPa8kB1Qebtp1t0OvESDDdwrmO') purchases = [] with open('purchaseRecord.csv') as csvfile: csvreader = csv.reader(csvfile) for row in csvreader: user_id = row[0] item_id = row[1] r = AddPurchase(user_id, item_id, cascade_create=True) purchases.append(r) br = Batch(purchases) print(br) client.send(br) recommended = client.send(UserBasedRecommendation('0', 5)) print(recommended)
def __init__(self, *args, **kwargs): super(RecombeeTest, self).__init__(*args, **kwargs) self.client = RecombeeClient('client-test', 'jGGQ6ZKa8rQ1zTAyxTc0EMn55YPF7FJLUtaMLhbsGxmvwxgTwXYqmUk5xVZFw98L')
import recombee_api_client from recombee_api_client.api_client import RecombeeClient from recombee_api_client.api_requests import * from .find_charity import * from .user_data import * import json from rounded.core import redis from .. import firebase import os from flask import current_app as app num_recs = 10 user = '******' client = RecombeeClient(*app.config.get("RECOMBEE")) global all_charity_data # client.send(AddItemProperty('cause', 'string')) # client.send(AddItemProperty('rating', 'int')) # client.send(AddItemProperty('state', 'string')) # def output_dict(): # return # all_charity_data = output_all() # print('done getting charities') # # db = connect_to_db() # db = redis.from_url(url)
from recombee_api_client.api_client import RecombeeClient from recombee_api_client.api_requests import * client = RecombeeClient( 'sns', 'cqLZqZnboKlyVKS7EhhYYyM8BflGRDlizngZbljA3kp67tjd1FKfH3WaXLNSXl7F') count = 1 users = [] for i in range(1, 102): request = DeleteUser(str(count)) count = count + 1 users.append(request) try: print('sending') client.send(Batch(users)) print('sent') except APIException as e: print(e)
class Recombee(object): def __init__(self, app=None): super(Recombee, self).__init__() if app: self.app = app self.load_recombee() def init_app(self, app): self.app = app self.load_recombee() def load_recombee(self): self.recombee_client = RecombeeClient(self.app.config['RECOMBEE_DB'], self.app.config['RECOMBEE_KEY']) def sync_user_data(self, user_id, data=[], timestamp=""): requests = [] for item in data: if item["ids"] is not None and len(item["ids"]) > 0: if item["view_type"] == "bet": for match_id in item["ids"]: r = AddPurchase( user_id, match_id, timestamp=timestamp, cascade_create=True ) requests.append(r) elif item["view_type"] == "scroll": for match_id in item["ids"]: r = SetViewPortion( user_id, match_id, portion=item["options"]["portion"] if item["options"]is not None else None, timestamp=timestamp, cascade_create=True ) requests.append(r) else: for match_id in item["ids"]: r = AddDetailView( user_id, match_id, timestamp=timestamp, cascade_create=True, duration=item["options"]["duration"] if item["options"] is not None else None ) requests.append(r) br = Batch(requests) result = self.recombee_client.send(br) def sync_item_data(self, matches=[]): requests = [] for match in matches: r = SetItemValues( match["id"], { "name": match["name"], "tags": [], "sourceID": match["source_id"], "categoryID": match["category_id"], "closeTime": match["date"] }, cascade_create=True ) requests.append(r) br = Batch(requests) self.recombee_client.send(br) def user_recommended_data(self, user_id, count=5, options=None): return self.recombee_client.send( RecommendItemsToUser( user_id, count, filter=options["filter"] if options is not None else None ) )