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

Post sort order #55

Closed
altexa opened this issue Dec 4, 2017 · 10 comments
Closed

Post sort order #55

altexa opened this issue Dec 4, 2017 · 10 comments

Comments

@altexa
Copy link

altexa commented Dec 4, 2017

Imported a list of posts from Chyrp.
Most-recent posts are listed at the top - this is fine.

Found a typo in the first post, edited it - leaving original timestamp. Save post.
It is now listed at the bottom (i.e. invisible). Also in admin, this post is last in the list.

Can posts be sorted automatically by timestamp descending?

@altexa
Copy link
Author

altexa commented Dec 4, 2017

image

@altexa
Copy link
Author

altexa commented Dec 4, 2017

This is the front page of the blog. As loaded by default.
Note recent posts list the two "what is backup software" posts (this is correct) - but the blog itself shows "Volume Shadow Copy" as the first post, while it should be third:

image

@xenocrat
Copy link
Owner

xenocrat commented Dec 4, 2017

Perhaps your post "Volume Shadow Copy" is pinned? This would cause it to appear above other posts in the blog index and the admin area. The usual sort order for both blog and admin area is pinned DESC, created_at DESC, id DESC.

What happens to the sort order if you edit some of the other posts?

@altexa
Copy link
Author

altexa commented Dec 5, 2017

Thanks for your reply - nothing is pinned.

Here's an extract of the database:

image

and the rest of the lines:

image

The updated_at is only filled for the posts I modified...don't know if this is linked to the fact that everything was imported.

@altexa
Copy link
Author

altexa commented Dec 5, 2017

....or maybe the sort problem is that the pinned field was not updated when the data was imported, and hence is null...and the update sets it to 0, and null comes before 0 in a sort

@xenocrat
Copy link
Owner

xenocrat commented Dec 5, 2017

Yes I think that may be the answer. Chyrp Lite will consider any “falsey” value as unpinned, but the database is prioritising null above 0 when it sorts the query results. The recent posts in the blog sidebar are not affected because the sort order for those results does not consider pinned status.

@altexa
Copy link
Author

altexa commented Dec 5, 2017

I'll update the DB manually, setting 'pinned' to 0 everywhere. Might be an idea (if possible) to set pinned to 0 on import, if not specified in the import file.

Thanks again

@altexa
Copy link
Author

altexa commented Dec 5, 2017

Confirmed, with a 0 in all lines, the sort is correct

@xenocrat
Copy link
Owner

xenocrat commented Dec 5, 2017

Yes, I’m going to look into this later today. The import method is casting the pinned value from the XML document to boolean but the normal behaviour for added/updated posts is to cast the value to integer, and I think this is causing different handling when sent to the database. Thanks for the report!

@altexa
Copy link
Author

altexa commented Dec 5, 2017

The thanks are mine ;)

xenocrat added a commit that referenced this issue Dec 5, 2017
Fixes bad pinned status and incorrect updated_at value reported in
issue #55.
@xenocrat xenocrat closed this as completed Jan 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants