~aleteoryx/muditaos

73b72b99ef854b1d1cb07cd4eef9688f84893391 — rrandomsky 2 years ago 4b7ccee
[MOS-471] Fix case sensitive in the note search

Changing the search engine in the notes application so that it is not case sensitive.
2 files changed, 8 insertions(+), 5 deletions(-)

M module-db/Tables/NotesTable.cpp
M pure_changelog.md
M module-db/Tables/NotesTable.cpp => module-db/Tables/NotesTable.cpp +7 -5
@@ 1,4 1,4 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "NotesTable.hpp"


@@ 125,14 125,16 @@ std::pair<std::vector<NotesTableRow>, int> NotesTable::getByText(const std::stri
                                                                 unsigned int limit)
{

    int count     = 0;
    auto queryRet = db->query("SELECT COUNT(*), INSTR(snippet," str_ ") pos FROM notes WHERE pos > 0;", text.c_str());
    int count = 0;
    auto queryRet =
        db->query("SELECT COUNT(*), INSTR(LOWER(snippet),LOWER(" str_ ")) pos FROM notes WHERE pos > 0;", text.c_str());
    if (queryRet && queryRet->getRowCount() != 0) {
        count = (*queryRet)[0].getUInt32();
    }

    std::string queryText = "SELECT *, INSTR(snippet,'" + text + "') pos FROM notes WHERE pos > 0 LIMIT " +
                            std::to_string(limit) + " offset " + std::to_string(offset) + " ;";
    std::string queryText = "SELECT *, INSTR(LOWER(snippet),LOWER('" + text +
                            "')) pos FROM notes WHERE pos > 0 LIMIT " + std::to_string(limit) + " offset " +
                            std::to_string(offset) + " ;";
    auto retQuery = db->query(queryText.c_str());

    if (retQuery == nullptr || retQuery->getRowCount() == 0) {

M pure_changelog.md => pure_changelog.md +1 -0
@@ 63,6 63,7 @@
* Fixed missing tethering icon on "Tethering is on" window.
* Fixed showing "Copy text" option in empty note.
* Fixed "Copy" option missing from the options list in "New message" window.
* Fixed unneeded case sensitiveness in the note search

## [1.7.2 2023-07-28]