Bug 386255

Summary: Dolphin's search bar date chooser uses relative terminology ("Today", "This month") but stores absolute dates for saved searches
Product: [Applications] dolphin Reporter: Nate Graham <nate>
Component: searchAssignee: Dolphin Bug Assignee <dolphin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: mail
Priority: NOR    
Version First Reported In: 18.04.2   
Target Milestone: ---   
Platform: Neon   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Nate Graham 2017-10-27 16:22:00 UTC
Dolphin's search bar date chooser uses relative terminology for dates ("Today", "This Month"), but under the good, it just uses them to return an absolute date:

QDate date = QDate::currentDate();
if (m_yesterday->isChecked()) {
    date = date.addDays(-1);
} else if (m_thisWeek->isChecked()) {
    date = date.addDays(1 - date.dayOfWeek());
} else if [...]

terms << QStringLiteral("modified>=%1").arg(date.toString(Qt::ISODate));
[...]
return terms.join(QStringLiteral(" AND "));


Ultimately the search URL is stored as an encoded string that evaluates to something like this:

baloosearch:?json={
    "dayFilter: 0,
    includeFolder: "/home/dev",
    "monthFilter: 0,
    "searchString: "modified>=2017-10-01 filename:\"foo%\",
    "term: {
        "$and: [
            {
                "modified: {
                    "$gte: "2017-10-01"
                }
            },
            {
                "filename: {
                    "$ct: "foo"
                }
            }
        ]
    },
    "yearFilter: 0
}
title=Query Results from 'foo'


This is problematic if you save the search for later use. The use of relative strings in the UI makes the user think that the search will be re-run relative to the current date, but instead it uses the date when the search was saved. So if a user saves a search using "This month" during the month of October, when November rolls around, the search will still only show results from October.

This is currently a minor bug since the saved search feature is quite hidden--you have to right-click on the background of the list of returned files and choose "Add to Places". But we are in the process of making the feature more discoverable with https://phabricator.kde.org/D8454, so this will become a more noticeable bug.

Let's use this bug to track any work we can do in Dolphin to resolve this (e.g. manually offsetting the date or using a new method of storing this information).

If any work is needed in Baloo (e.g. providing a date offset translation function or a net method of storing relative dates), let's track that there.
Comment 1 Julian Steinmann 2018-06-29 16:06:40 UTC
I think we should treat this as a bug and because this behavior is still the same with Dolphin 18.04.2, I'll set the status to CONFIRMED.
Comment 2 Nate Graham 2021-10-24 14:01:35 UTC
No longer relevant