Skip to content
This repository has been archived by the owner on Mar 24, 2020. It is now read-only.

RDCP: Sort by system modified date in browse by collection view #663

Merged
merged 4 commits into from
Jun 20, 2019

Conversation

mcritchlow
Copy link
Member

@mcritchlow mcritchlow commented Jun 19, 2019

Fixes #644

Local Checklist

  • Tests written and passing locally?
  • Code style checked?
  • QA-ed locally?
  • Rebased with master branch?
  • Configuration updated (if needed)?
  • Documentation updated (if needed)?

What does this PR do?

  • Sorts rdcp browse by collection view by system_modified date descending, with title ascending as a secondary sort parameter
  • Adds tests demonstrating this behavior for RDCP, but not for other units (DLDP)
  • Adds timecop gem to easily support time-sensitive tests, which were relevant for the behavior in this PR
  • Fixed a leaky test unit object that showed up in a failed CI run. This is not completely related, but seems problematic and worth fixing (I worry we have other examples of this..)
Why are we doing this? Any context of related work?

References #644 - for RDCP

@ucsdlib/developers - please review

Copy link
Member

@lsitu lsitu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcritchlow It looks good. Just curios regarding those two questions. Thanks.


# RDCP prefers their collections sorted by most recently created first
# Therefore, we're sorting by modified date rather than title
params[:sort] = 'system_modified_dtsi desc, title_ssi asc' if params[:id].eql? 'rdcp'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this line can be in front of line#309 if the condition is correct? It may not be a big deal but just curios regarding the condition unless params[:sort] in line#309 works.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking was that this would be last in the chain of sorting checks. If I put it above, then it could potentially get overwritten later. But I may be misunderstanding you, can you help clarify with an example maybe?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcritchlow I think it's just related to your last comment in #663 (comment). The default sort by title will be set with the unless params[:sort] in https://github.com/ucsdlib/damspas/pull/663/files#diff-956e46b33fb5307990c4e1a4b5fd86ccR309 only when there are no sort order rules are selected.

old_collection_sort_order = page.body.index('A Old Collection')
new_collection_sort_order = page.body.index('The New Collection')
expect(old_collection_sort_order).to be > new_collection_sort_order
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a test for user selected sorting rules like sort by collection title to see whether it works? It seems like there could be a gap but I may be wrong. See my other comment above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default sort I think is tested in the DLDP browse test I wrote below the RDCP one, which basically demonstrates the normal alphabetical sort. Can you take a look at that again and let me know if you think there's still a gap that needs testing? It's certainly possible :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lsitu - Oh, I apologize. You're saying if a user selects different sorting rules after the page has initially loaded. That's a really great point, and possibly a regression. The current code might always force this sorting for RDCP. I understand what you're saying now, thanks for pointing this out. I'll think about how to adjust for this.

- Only apply RDCP sorting if a user has not already selected a sort
  option in the UI
- Adds a test for a user selected option when browsing RDCP collections
@mcritchlow
Copy link
Member Author

@lsitu - Thank you again for catching the user-selected sorting regression! I've changed the code in catalog controller to only apply those defaults if no sorting option has been selected by the user. And I added a test to confirm that.

Let me know if you think this works.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.008%) to 65.801% when pulling 7a26832 on feature/rdcp-collection-sort into 7ff5d10 on master.

Copy link
Member

@lsitu lsitu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcritchlow It looks good! 👍

@hweng
Copy link
Contributor

hweng commented Jun 20, 2019

👍

@hweng hweng merged commit fa51fcf into master Jun 20, 2019
@hweng hweng deleted the feature/rdcp-collection-sort branch June 20, 2019 20:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sort collections view by most recently added, by default
4 participants