Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/08/2014 06:55:30 AM (11 years ago)
Author:
imath
Message:

Insert a new "since" filter for the activity stream to be used by HeartBeat check feature

In rare cases, the field date_recorded of the activity table can be updated to a date greater than the most recent activity in terms of id.
The Heartbeat feature was based on the id field so far, while the activity stream is sorting items according to the date_recorded field. As a result, in this very particular case, activities with an id greater than the activity (which date has been updated) will be loaded again in the stream and this until a new activity is published.
To prevent this to happen, we introduce this new "since" filter to be used by the HeartBeat feature once it gets the timestamp of the most recent activity displayed in the stream.

props SGr33n, boonebgorges, imath

Fixes #5505

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/testcases/activity/class.BP_Activity_Activity.php

    r8249 r8251  
    283283        $this->assertEquals( array( $a3, $a2 ), $ids );
    284284    }
     285
     286    /**
     287     * @group get
     288     */
     289    public function test_get_with_since() {
     290        $now = time();
     291        $a1 = $this->factory->activity->create( array(
     292            'content' => 'Life Rules',
     293            'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
     294        ) );
     295        $a2 = $this->factory->activity->create( array(
     296            'content' => 'Life Drools',
     297            'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ),
     298        ) );
     299        $a3 = $this->factory->activity->create( array(
     300            'content' => 'Life Drools',
     301            'recorded_time' => date( 'Y-m-d H:i:s', $now - 10 ),
     302        ) );
     303
     304        $activity = BP_Activity_Activity::get( array(
     305            'filter' => array(
     306                'since' => date( 'Y-m-d H:i:s', $now - 70 ),
     307            ),
     308        ) );
     309        $ids = wp_list_pluck( $activity['activities'], 'id' );
     310        $this->assertEquals( array( $a3, $a2 ), $ids );
     311    }
     312
    285313    /**
    286314     * @group get_id
Note: See TracChangeset for help on using the changeset viewer.