Skip to content

Commit a8dc14d

Browse files
authored
Merge pull request #65 from mongodb/development
Merge development into main
2 parents 8de232d + 40ff772 commit a8dc14d

32 files changed

Lines changed: 1306 additions & 744 deletions

File tree

.github/workflows/run-python-tests.yml

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,58 @@ jobs:
3838
- name: Download sample data
3939
run: curl https://atlas-education.s3.amazonaws.com/sampledata.archive -o sampledata.archive
4040

41-
- name: Add sample data to database
42-
run: mongorestore --archive=sampledata.archive --port=27017
41+
- name: Setup Database (Data & Indexes)
42+
run: |
43+
# 1. Restore the data
44+
mongorestore --archive=sampledata.archive --port=27017
45+
46+
# 2. Prepare the Search Index Definition
47+
echo '{
48+
"name": "movieSearchIndex",
49+
"database": "sample_mflix",
50+
"collectionName": "movies",
51+
"mappings": {
52+
"dynamic": false,
53+
"fields": {
54+
"plot": {"type": "string", "analyzer": "lucene.standard"},
55+
"fullplot": {"type": "string", "analyzer": "lucene.standard"},
56+
"directors": {"type": "string", "analyzer": "lucene.standard"},
57+
"writers": {"type": "string", "analyzer": "lucene.standard"},
58+
"cast": {"type": "string", "analyzer": "lucene.standard"}
59+
}
60+
}
61+
}' > search_index.json
62+
63+
# 3. Create the Search Index
64+
atlas deployments search indexes create \
65+
--deploymentName myLocalRs1 \
66+
--file search_index.json
67+
68+
# 4. Prepare the Vector Index Definition
69+
echo '{
70+
"name": "vector_index",
71+
"database": "sample_mflix",
72+
"collectionName": "embedded_movies",
73+
"type": "vectorSearch",
74+
"fields": [
75+
{
76+
"type": "vector",
77+
"path": "plot_embedding_voyage_3_large",
78+
"numDimensions": 2048,
79+
"similarity": "cosine"
80+
}
81+
]
82+
}' > vector_index.json
4383
84+
# 5. Create the Vector Index
85+
atlas deployments search indexes create \
86+
--deploymentName myLocalRs1 \
87+
--file vector_index.json
88+
89+
# 6. Wait for indexes to build
90+
echo "Waiting for indexes to build..."
91+
sleep 20
92+
4493
- name: Set up Python
4594
uses: actions/setup-python@v5
4695
with:
@@ -63,10 +112,10 @@ jobs:
63112

64113
- name: Run integration tests
65114
working-directory: mflix/server/python-fastapi
66-
run: pytest -m integration --verbose --tb=short --junit-xml=test-results-integration.xml || true
115+
run: pytest -m integration --verbose --tb=short --junit-xml=test-results-integration.xml
67116
env:
68-
MONGO_URI: mongodb://localhost:27017
69-
MONGO_DB: sample_mflix
117+
MONGO_URI: mongodb://localhost:27017/?directConnection=true
118+
MONGO_DB: sample_mflix
70119

71120
- name: Upload test results
72121
uses: actions/upload-artifact@v4

mflix/client/app/aggregations/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
2-
import { fetchMoviesWithComments, fetchMoviesByYear, fetchDirectorStats } from '../lib/api';
3-
import { MovieWithComments, YearlyStats, DirectorStats } from '../types/aggregations';
2+
import { fetchMoviesWithComments, fetchMoviesByYear, fetchDirectorStats } from '@/lib/api';
3+
import { MovieWithComments, YearlyStats, DirectorStats } from '@/types/aggregations';
44
import styles from './aggregations.module.css';
55

66
export default async function AggregationsPage() {

mflix/client/app/components/MovieCard/MovieCard.module.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,17 @@
105105
font-size: 14px;
106106
}
107107

108+
.vectorScore {
109+
margin: 0 0 4px 0;
110+
color: #0066cc;
111+
font-size: 13px;
112+
font-weight: 500;
113+
background: #e6f0ff;
114+
padding: 4px 8px;
115+
border-radius: 4px;
116+
display: inline-block;
117+
}
118+
108119
.movieGenres {
109120
margin: 0;
110121
color: #888;

mflix/client/app/components/MovieCard/MovieCard.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ export default function MovieCard({ movie, isSelected = false, onSelectionChange
6969
{movie.year && (
7070
<p className={movieStyles.movieYear}>({movie.year})</p>
7171
)}
72+
{movie.score !== undefined && (
73+
<p className={movieStyles.vectorScore}>
74+
🎯 Vector Score: {movie.score.toFixed(4)}
75+
</p>
76+
)}
7277
{movie.imdb?.rating && (
7378
<p className={movieStyles.movieRating}>{movie.imdb.rating}/10</p>
7479
)}

0 commit comments

Comments
 (0)