"CREATE TABLE IF NOT EXISTS "
"search (keywords text, uri text, day integer);"
"CREATE TEMP VIEW history_view AS SELECT "
- "1 AS type, uri, title FROM history;"
+ "1 AS type, uri, title, day FROM history;"
"CREATE TEMP VIEW search_view AS SELECT "
- "2 AS type, uri, keywords AS title FROM search;",
+ "2 AS type, uri, keywords AS title, day FROM search;",
NULL, NULL, errmsg) != SQLITE_OK)
return NULL;
sqlcmd = "SELECT type, uri, title, count() AS ct FROM history_view "
"WHERE uri LIKE ?1 OR title LIKE ?1 GROUP BY uri "
"UNION ALL "
- "SELECT type, uri, title, count() AS ct FROM search_view "
+ "SELECT type, replace(uri, '%s', title) AS uri, title, count() AS ct FROM search_view "
"WHERE title LIKE ?1 GROUP BY uri "
"ORDER BY ct DESC LIMIT ?2";
sqlite3_prepare_v2 (db, sqlcmd, strlen (sqlcmd) + 1, &stmt, NULL);
FAVICON_COL, icon, -1);
else if (type == 2 /* search_view */)
{
- gchar* search_uri = sokoke_search_uri ((gchar*)uri, (gchar*)title);
gchar* search_title = g_strdup_printf (_("Search for %s"), title);
gtk_list_store_insert_with_values (store, NULL, matches,
- URI_COL, search_uri, TITLE_COL, search_title, YALIGN_COL, 0.25,
+ URI_COL, uri, TITLE_COL, search_title, YALIGN_COL, 0.25,
STYLE_COL, 1, FAVICON_COL, icon, -1);
- g_free (search_uri);
g_free (search_title);
}
{
gchar* filterstr;
- sqlcmd = "SELECT uri, title, date "
- "FROM history WHERE uri LIKE ? or title LIKE ? "
- "GROUP BY uri ORDER BY date ASC";
+ sqlcmd = "SELECT uri, title, day FROM history_view "
+ "WHERE uri LIKE ? or title LIKE ? GROUP BY uri "
+ "UNION ALL "
+ "SELECT replace(uri, '%s', title) AS uri, title, day "
+ "FROM search_view WHERE title LIKE ?1 GROUP BY uri "
+ "ORDER BY day ASC";
result = sqlite3_prepare_v2 (db, sqlcmd, -1, &statement, NULL);
filterstr = g_strdup_printf ("%%%s%%", filter);
sqlite3_bind_text (statement, 1, filterstr, -1, g_free);