After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 762240 - Don't use more than 5 years in the search popover
Don't use more than 5 years in the search popover
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-02-18 08:41 UTC by Carlos Soriano
Modified: 2016-02-24 13:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Search popover: limit options to max 5 years (2.54 KB, patch)
2016-02-18 16:09 UTC, Alexandru Pandelea
reviewed Details | Review
Search popover: limit options to max 5 years(update) (2.85 KB, patch)
2016-02-22 13:48 UTC, Alexandru Pandelea
none Details | Review
Search popover: limit options to max 5 years(update 2) (3.11 KB, patch)
2016-02-23 19:13 UTC, Alexandru Pandelea
needs-work Details | Review
Search popover: limit options to max 5 years (4.00 KB, patch)
2016-02-24 12:50 UTC, Alexandru Pandelea
committed Details | Review

Description Carlos Soriano 2016-02-18 08:41:07 UTC
It's overkill, and will allow us to improve a little that tricky code to generate those.
Comment 1 Alexandru Pandelea 2016-02-18 16:09:07 UTC
Created attachment 321596 [details] [review]
Search popover: limit options to max 5 years

The list displayed too many options for older dates.

To fix this I've modified the number of days for the loop that
generated those options. Besides this I've also removed two
conditions that are made redundant due to this change.
Comment 2 Carlos Soriano 2016-02-21 22:05:00 UTC
Review of attachment 321596 [details] [review]:

Thanks for the patch! It's almost good. See small fixes inline:

::: src/nautilus-search-popover.c
@@ +26,3 @@
 #include <libnautilus-private/nautilus-global-preferences.h>
 
+#define MAX_SEARCH_YEARS 5

Just a nitpick, we can search for more than 5 years. Just that the filter does not :)

How about the name for the constant be SEARCH_FILTER_MAX_YEARS?

@@ +381,3 @@
   maximum_dt = g_date_time_new_from_unix_local (0);
   now = g_date_time_new_now_local ();
+  max_days = (MAX_SEARCH_YEARS + 1) * 365;

Why +1?? We want effectively 5 years.
Comment 3 Alexandru Pandelea 2016-02-22 13:48:13 UTC
Created attachment 321842 [details] [review]
Search popover: limit options to max 5 years(update)

You're right about the constant name, so I've renamed it.

About the +1, The reason I used it it's because after the
first year, the variable days is equal to 371 so there is
a +6 because of the step. But if I change the step, there
wouldn't be displayed the same entries. I know it's not
the perfect solution, so if you consider something else
would be better I'll change it :)
Comment 4 Carlos Soriano 2016-02-23 12:50:07 UTC
(In reply to Alexandru Pandelea from comment #3)
> Created attachment 321842 [details] [review] [review]
> Search popover: limit options to max 5 years(update)
> 
> You're right about the constant name, so I've renamed it.
> 
> About the +1, The reason I used it it's because after the
> first year, the variable days is equal to 371 so there is
> a +6 because of the step. But if I change the step, there
> wouldn't be displayed the same entries. I know it's not
> the perfect solution, so if you consider something else
> would be better I'll change it :)

Sorry took long time to review. Now I'm more free.

So if the problem is the days var has an offset, remove it.

Maybe something like:
      else if (days < 365)
        {
          /* months */
          normalized = days / 30;
          /* Make sure we don't have an offset */
          if (normalized == 1)
            days = 30;
          step = 84;
        }
Comment 5 Carlos Soriano 2016-02-23 12:50:37 UTC
And also the step of the months is wrong (not your fault), you can change it to 90 if you want :)
Comment 6 Alexandru Pandelea 2016-02-23 19:13:29 UTC
Created attachment 322164 [details] [review]
Search popover: limit options to max 5 years(update 2)

Removing the offset in the else corresponding to years
solved the problem with the +1.

I've also changed the step to 90.

I hope that now it's ok, but if there's something that has
to be changed please tell me :)
Comment 7 Carlos Soriano 2016-02-24 10:10:45 UTC
Review of attachment 322164 [details] [review]:

Ok we are getting there! Few things:
The commit message contains a (update 2) thing, which shouldn't be part of it.
Also you report in the commit message things from a previous patch that are not longer needed. You need to do a single patch that fixes the issue, not a serie of patches.
Don't use the "I", instead use impersonal voice like: "Also fix the step value for every section".
Read more about commit guidelines here:
https://wiki.gnome.org/Newcomers/CodeContributionWorkflow#Commit_guidelines

Also a inline comment:

::: src/nautilus-search-popover.c
@@ +421,3 @@
           normalized = days / 365;
+          if (normalized == 1)
+          	days = 365;

This problem happens with every section, so I would add this to every one of them.
Also add a comment to explain why this is necesary. You can add it before the "while" statement
Comment 8 Alexandru Pandelea 2016-02-24 12:50:26 UTC
Created attachment 322233 [details] [review]
Search popover: limit options to max 5 years

The list displayed too many options for older dates.

In order to limit this, the max_days variable was decreased to
the number of days corresponding to 5 years

The value of the step for months was updated to the proper value, 90.

The days variable contained an unnecessary offset. To prevent it,
for the first occurrence of each timeslice (month, week, year) there
was added an if clause to remove the offset

Due to limiting the max number of years displayed, there was removed
(a now redundant) else from the function get_text_for_date_range.
Comment 9 Carlos Soriano 2016-02-24 12:56:35 UTC
Review of attachment 322233 [details] [review]:

Cool! That looks good now, thanks for the patch!
Comment 10 Carlos Soriano 2016-02-24 13:02:25 UTC
Attachment 322233 [details] pushed as 2cc130d - Search popover: limit options to max 5 years