@@ -197,7 +197,7 @@ std::vector<int> DbManager::getUrlsIdsByWord(std::string word)
197
197
std::string wordIdStr = std::to_string (wordId);
198
198
199
199
pqxx::work tx{ *conn };
200
- for (auto [id] : tx.query <int >(" select id from frequencies " " where word_id = '" + tx.esc (wordIdStr) + " ';" )) {
200
+ for (auto [id] : tx.query <int >(" select url_id from frequencies " " where word_id = '" + tx.esc (wordIdStr) + " ';" )) {
201
201
urlIds.push_back (id);
202
202
}
203
203
return urlIds;
@@ -209,7 +209,7 @@ std::vector<int> DbManager::getUrlsIdsByWords(std::vector<std::string> words)
209
209
std::vector<int > urlIdsAccepted;
210
210
std::vector<int > word_ids = getWordsIds (words);
211
211
pqxx::work tx{ *conn };
212
- for (auto [urlIdd] : tx.query <int >(" select url_id from frequencies " " where word_id in ' " + getStringFromVector (word_ids) + " ' ;" )) {
212
+ for (auto [urlIdd] : tx.query <int >(" select url_id from frequencies " " where word_id in ( " + getStringFromVector (word_ids) + " ) ;" )) {
213
213
urlIds.push_back (urlIdd);
214
214
}
215
215
@@ -230,12 +230,12 @@ std::vector<std::string> DbManager::getSortedUrlsByWords(std::vector<std::string
230
230
231
231
std::vector<std::string> sortedUrls;
232
232
pqxx::work tx{ *conn };
233
- for (auto & [url, freq] : tx.query <std::string, int >(" select u.url, sum(f.frequency) sum_freq from frequencies f"
234
- " join words w on f.word_id = w.id"
235
- " join urls u on f.url_id = u.id"
236
- " where word_id in (" + getStringFromVector (word_ids) + " )"
237
- " and url_id in (" + getStringFromVector (url_ids) + " )"
238
- " group by url"
233
+ for (auto & [url, freq] : tx.query <std::string, int >(" select u.url, sum(f.frequency) sum_freq from frequencies f "
234
+ " join words w on f.word_id = w.id "
235
+ " join urls u on f.url_id = u.id "
236
+ " where word_id in (" + getStringFromVector (word_ids) + " ) "
237
+ " and url_id in (" + getStringFromVector (url_ids) + " ) "
238
+ " group by url "
239
239
" order by sum_freq DESC" )) {
240
240
sortedUrls.push_back (url);
241
241
}
0 commit comments