Skip to content

Commit

Permalink
Merge pull request #20 from dataforgoodfr/improve-search
Browse files Browse the repository at this point in the history
Improve search
  • Loading branch information
kaaloo authored Apr 13, 2024
2 parents 3212958 + 8c0e31d commit db436ac
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 5 deletions.
33 changes: 32 additions & 1 deletion site-observable/docs/data/films.sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,38 @@
df = df[df["release_date"] < now]

# Remove movies with no known revenue
df = df[df["revenue"] > 0]
# and original_language other than EU languages
df = df[
(df["revenue"] == 0)
& (
df["original_language"].isin(
[
"cs",
"da",
"de",
"en",
"es",
"et",
"fi",
"fr",
"hr",
"hu",
"is",
"it",
"lt",
"lv",
"nl",
"no",
"pl",
"pt",
"ro",
"sl",
"sv",
],
)
)
| (df["revenue"] > 0)
]

# Add a column with the production_year based on the release_date
df["production_year"] = df["release_date"].dt.year
Expand Down
16 changes: 14 additions & 2 deletions site-observable/docs/films.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,20 @@ const db = FileAttachment("data/films.sqlite").sqlite();

```js
const results = db.query(
`SELECT *, (SELECT COUNT(*) FROM films) total FROM films WHERE films.title LIKE ? COLLATE NOCASE ORDER BY films.title LIMIT 20`,
[`${query}%`]
`
SELECT
*,
(SELECT COUNT(*) FROM films) total
FROM
films
WHERE
films.title LIKE ? COLLATE NOCASE
OR films.original_title LIKE ? COLLATE NOCASE
ORDER BY
films.title
LIMIT
20`,
[`%${query}%`, `%${query}%`]
);
```

Expand Down
15 changes: 13 additions & 2 deletions site-observable/docs/shows.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,19 @@ const db = FileAttachment("data/shows.sqlite").sqlite();

```js
const results = db.query(
`SELECT *, (SELECT COUNT(*) FROM shows) total FROM shows WHERE shows.name LIKE ? COLLATE NOCASE ORDER BY shows.name ASC LIMIT 20`,
[`${query}%`]
`
SELECT
*,
(SELECT COUNT(*) FROM shows) total
FROM
shows
WHERE
shows.name LIKE ? COLLATE NOCASE OR
shows.original_name LIKE ? COLLATE NOCASE
ORDER BY
shows.name ASC
LIMIT 20`,
[`%${query}%`, `%${query}%`]
);
```

Expand Down

0 comments on commit db436ac

Please sign in to comment.