Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting in albums should be rather "dateTaken,asc" #1340

Open
ghost opened this issue Jul 24, 2013 · 7 comments
Open

Sorting in albums should be rather "dateTaken,asc" #1340

ghost opened this issue Jul 24, 2013 · 7 comments

Comments

@ghost
Copy link

ghost commented Jul 24, 2013

Hi guys, this is definitely not very clean way of doing it (that's why I'm not sending it as git push request), but here is the idea: Let's serve photos for albums in different order according to "album" filter, before somebody makes the option to select sorting method for every album. Or not?

diff --git a/src/libraries/adapters/DatabaseMySql.php b/src/libraries/adapters/DatabaseMySql.php
index 0d4ee21..ebc597e 100644
--- a/src/libraries/adapters/DatabaseMySql.php
+++ b/src/libraries/adapters/DatabaseMySql.php
@@ -1712,6 +1712,8 @@ class DatabaseMySql implements DatabaseInterface
             if($value === 'dateTaken,desc')
               $sortBy = 'ORDER BY dateSortByDay DESC';
             elseif($value === 'dateTaken,asc')
+              $sortBy = 'ORDER BY dateTaken ASC';
+            elseif($value === 'dateTaken,asc')
               $sortBy = 'ORDER BY dateSortByDay ASC';
             elseif($value === 'dateUploaded,desc')
               $sortBy = 'ORDER BY dateSortByDay DESC, dateUploaded ASC';
diff --git a/src/libraries/controllers/ApiPhotoController.php b/src/libraries/controllers/ApiPhotoController.php
index a17bf9a..fd64157 100644
--- a/src/libraries/controllers/ApiPhotoController.php
+++ b/src/libraries/controllers/ApiPhotoController.php
@@ -241,6 +241,11 @@ class ApiPhotoController extends ApiBaseController
   {
     // this extracts local variables $permission, $filter, $pageSize, etc
     extract($this->parseFilters($filterOpts));
+
+    // fix for sorting in albums
+    if(isset($filters['album']))
+      $filters['sortBy'] = 'dateTaken,asc';
+
     $db = getDb();
     $photos = $db->getPhotos($filters, $pageSize);
@hfiguiere
Copy link
Member

When I read the whole block you modified things in, I believe it is all wrong.

@hfiguiere
Copy link
Member

          case 'sortBy':
            if($value === 'dateTaken,desc')
              $sortBy = 'ORDER BY dateSortByDay DESC';
            elseif($value === 'dateTaken,asc')
              $sortBy = 'ORDER BY dateSortByDay ASC';

You should change BOTH if()

            elseif($value === 'dateUploaded,desc')
              $sortBy = 'ORDER BY dateSortByDay DESC, dateUploaded ASC';
            elseif($value === 'dateUploaded,asc')
              $sortBy = 'ORDER BY dateSortByDay ASC, dateUploaded ASC';

And here too.

            else
              $sortBy = 'ORDER BY ' . $this->_(str_replace(',', ' ', $value));

@hfiguiere
Copy link
Member

Btw this is bug #735 and bug #1339

@ghost
Copy link
Author

ghost commented Jul 24, 2013

Sort of, but actually dateTaken,desc in my code is not oposite to dateTaken,asc. (!)

I know about #735, but the proposed solution there is too complex. I missed #1339, sorry.

@jmathai
Copy link
Member

jmathai commented Jul 26, 2013

Taking a step back and opening this up for discussion with the hopes that we can decide on a good default based on all the perspectives we get. #1341

jmathai added a commit that referenced this issue Oct 18, 2013
hfiguiere added a commit to hfiguiere/frontend that referenced this issue Aug 17, 2014
@hfiguiere
Copy link
Member

And this because the previous commit is nowhere to be found.
upstream/4.0.2-rc3
upstream/gh-1402

Then

hfiguiere added a commit to hfiguiere/frontend that referenced this issue Aug 17, 2014
@hfiguiere hfiguiere self-assigned this Aug 17, 2014
@hfiguiere
Copy link
Member

The fix above is actually for bug #1286.

@hfiguiere hfiguiere removed their assignment Aug 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants