Skip to content
Snippets Groups Projects
Verified Commit a77db239 authored by Frank Sauerburger's avatar Frank Sauerburger
Browse files

Add movie ids

parent 36d6c564
No related branches found
No related tags found
No related merge requests found
Pipeline #9638 passed
TAG=0.2.0
TAG=0.3.0
build:
DOCKER_DEFAULT_PLATFORM=linux/amd64 docker build -t gitlab.sauerburger.com:5049/frank/wakefield-movie-recommender:$(TAG) .
......
......@@ -12,21 +12,38 @@ app = Flask(__name__)
with open("examples/titles.json", encoding="utf-8") as fileobj:
titles = json.load(fileobj)
movie_ids = {}
index = qgram.QGramIndex()
for title, _ in titles.values():
for tid, (title, _) in titles.items():
movie_ids[title] = int(tid)
index.add_term(title)
@app.route("/titles")
def suggest():
"""Serve movie title suggestions"""
query = request.args.get("q")
try:
length = int(request.args.get("l", 12))
length = min(length, 100)
except ValueError:
length = 12
results = []
if query:
results = index.search(query)
results = results[:length]
results = [
(score, title, movie_ids[title])
for score, title in results
]
return {
"suggestions": results[:100]
"suggestions": results
}
@app.route("/titles/healthz")
......
......@@ -16,7 +16,7 @@ spec:
spec:
containers:
- name: titles
image: gitlab.sauerburger.com:5049/frank/wakefield-movie-recommender:0.2.0
image: gitlab.sauerburger.com:5049/frank/wakefield-movie-recommender:0.3.0
livenessProbe:
httpGet:
path: /titles/healthz
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment