recommender now returns ids instead of products
This commit is contained in:
parent
fd6b66faeb
commit
0cf418df99
3 changed files with 75 additions and 82 deletions
|
@ -47,7 +47,7 @@ message ListRecommendationsRequest {
|
|||
}
|
||||
|
||||
message ListRecommendationsResponse {
|
||||
repeated Product products = 1;
|
||||
repeated string product_ids = 1;
|
||||
}
|
||||
|
||||
// ---------------Product Catalog----------------
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,22 +4,16 @@ import demo_pb2_grpc
|
|||
from concurrent import futures
|
||||
import time
|
||||
import sys
|
||||
import random
|
||||
|
||||
class RecommendationService(demo_pb2_grpc.RecommendationServiceServicer):
|
||||
def ListRecommendations(self, request, context):
|
||||
print("handling request")
|
||||
response = demo_pb2.ListRecommendationsResponse()
|
||||
prod_list = []
|
||||
for i in range(3):
|
||||
this_price = demo_pb2.MoneyAmount(decimal=i,
|
||||
fractional=i)
|
||||
this_prod = demo_pb2.Product(id=i,
|
||||
name="test-"+str(i),
|
||||
description="test product",
|
||||
picture="test image",
|
||||
price_usd=this_price)
|
||||
prod_list.append(this_prod)
|
||||
response.products.extend(prod_list)
|
||||
for i in range(5):
|
||||
prod_list.append(str(random.randint(1,100)))
|
||||
response.product_ids.extend(prod_list)
|
||||
return response
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in a new issue