Skip to content

Commit

Permalink
Remove last occurences of city_favourites. Closes #33
Browse files Browse the repository at this point in the history
  • Loading branch information
martinheppner committed Oct 15, 2023
1 parent a49c9f1 commit 09bc6cd
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
9 changes: 0 additions & 9 deletions database.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
DROP TABLE IF EXISTS city;
DROP TABLE IF EXISTS city_favourites;
DROP TABLE IF EXISTS fahrplan;
DROP TABLE IF EXISTS fahrplan_del;
DROP TABLE IF EXISTS fahrplan_load;
Expand Down Expand Up @@ -85,14 +84,6 @@ CREATE TABLE city (

CREATE INDEX ON city (city_slug);

CREATE TABLE city_favourites (
city_slug varchar(64) NOT NULL,
city_name varchar(128) NOT NULL,
city_country varchar(128) NOT NULL,
search_count int NOT NULL DEFAULT 0,
PRIMARY KEY (city_slug)
);

CREATE TABLE fahrplan (
id SERIAL,
tour_provider varchar(30) NOT NULL,
Expand Down
5 changes: 1 addition & 4 deletions src/routes/cities.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ const listWrapper = async (req, res) => {
if(!!search && search.length > 0){
result = await knex('city').select().where(where).andWhereRaw(`LOWER(city_name) LIKE '%${search.toLowerCase()}%'`).orderBy('city', 'asc').limit(100);
} else {
result = await knex('city_favourites').select().where(where).orderBy('search_count', 'desc').limit(100);
if(!!!result || result.length === 0){
result = await knex('city').select().where(where).orderBy('city', 'asc').limit(100);
}
result = await knex('city').select().where(where).orderBy('city', 'asc').limit(100);
}
}

Expand Down

0 comments on commit 09bc6cd

Please sign in to comment.