Skip to:
Content

BuddyPress.org

Opened 7 weeks ago

Last modified 2 weeks ago

#8488 new enhancement

Support date queries for members, groups and sites

Reported by: r-a-y Owned by:
Milestone: Up Next Priority: normal
Severity: normal Version:
Component: Core Keywords: has-patch
Cc:

Description

We already support date queries for the activity and notification loops. Let's introduce date queries for the rest of our component loops -- members, groups and sites!

As I began adding date query to these components, there are two things I wanted to address:

  1. For our existing date query integrations, we manually strip the initial 'AND' SQL clause created by WP_Date_Query

See:

This is a little messy. WP_Date_Query has seen some improvements to abstract some of this behavior.

So in the attached patch, I've modified our BP_Date_Query class so we can choose to prepend the AND SQL operator if we wanted to. See BP_Date_Query::__construct() for the new $prepend_and function argument, which I've defaulted to false. The only time we set this to true is for the sites component, which uses a messy SQL clause.

I've also created a new utility static method, BP_Date_Query::get_where_sql(). This is to be used where we want to initialize a new date query. See the new date query additions to members, groups and sites.

  1. Blogs component needs some love to use array as a function argument

Similar to what we did with the members component in #3797, I wanted to do the same thing for the blogs loop. So that's what I did here.

I've also cleaned up the PHPDoc as well.


Now that we've gotten that out of the way, let me explain how date queries will work in each of the components:

  • For members, we will only allow date queries if the $type in bp_has_members() is either active, newest, random or online.
  • For groups, we will only allow date queries if the $type in bp_has_groups() is either active or newest.
  • For sites, we will only allow date queries if the $type in bp_has_blogs() is either active or newest.

This is done because these types use a date to compare against. The other types like alphabetical or popular do not make much sense to use a date query with.

I've also added some unit tests for each component as well. Let me know what you think.

Attachments (1)

8488.01.patch (46.4 KB) - added by r-a-y 7 weeks ago.

Download all attachments as: .zip

Change History (3)

@r-a-y
7 weeks ago

#1 @imath
6 weeks ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 9.0.0

Hi @r-a-y

I haven't tested it yet, but I believe it's a great idea. Thanks for working on it.

#2 @imath
2 weeks ago

  • Milestone changed from 9.0.0 to Up Next

Hi @r-a-y

I'm really sorry I couldn't find the time to test your patch. We've decided 9.0.0 would be a short development cycle focused on Widget Blocks (as 5.8 is introducing new features about this area).

Let's have date queries ready for 10.0.0 !!

Note: See TracTickets for help on using tickets.