Remove search terms from WikivoyageSearchResult; make wikivoyage search query distinct

This commit is contained in:
Alex Sytnyk 2018-04-04 12:33:59 +03:00
parent a7c5736e78
commit 04df3d987c
2 changed files with 6 additions and 14 deletions

View file

@ -62,8 +62,7 @@ public class WikivoyageDbHelper {
private static final String SEARCH_COL_ARTICLE_TITLE = "article_title";
private static final String SEARCH_COL_LANG = "lang";
private static final String SEARCH_QUERY = "SELECT " +
SEARCH_COL_SEARCH_TERM + ", " +
private static final String SEARCH_QUERY = "SELECT DISTINCT " +
SEARCH_TABLE_NAME + "." + SEARCH_COL_CITY_ID + ", " +
SEARCH_COL_ARTICLE_TITLE + ", " +
SEARCH_TABLE_NAME + "." + SEARCH_COL_LANG + ", " +
@ -144,7 +143,6 @@ public class WikivoyageDbHelper {
}
prev.articleTitles.add(insInd, rs.articleTitles.get(0));
prev.langs.add(insInd, rs.langs.get(0));
prev.searchTerms.add(insInd, rs.searchTerms.get(0));
} else {
wikivoyage.put(rs.cityId, rs);
}
@ -183,12 +181,11 @@ public class WikivoyageDbHelper {
private WikivoyageSearchResult readSearchResult(SQLiteCursor cursor) {
WikivoyageSearchResult res = new WikivoyageSearchResult();
res.searchTerms.add(cursor.getString(0));
res.cityId = cursor.getLong(1);
res.articleTitles.add(cursor.getString(2));
res.langs.add(cursor.getString(3));
res.isPartOf = cursor.getString(4);
res.imageTitle = cursor.getString(5);
res.cityId = cursor.getLong(0);
res.articleTitles.add(cursor.getString(1));
res.langs.add(cursor.getString(2));
res.isPartOf = cursor.getString(3);
res.imageTitle = cursor.getString(4);
return res;
}

View file

@ -9,17 +9,12 @@ public class WikivoyageSearchResult {
private static final int SHOW_LANGS = 3;
List<String> searchTerms = new ArrayList<>();
long cityId;
List<String> articleTitles = new ArrayList<>();
List<String> langs = new ArrayList<>();
String isPartOf;
String imageTitle;
public List<String> getSearchTerms() {
return searchTerms;
}
public long getCityId() {
return cityId;
}