Remove unused method EchoEventMapper::fetchByUserBundleHash

Bug: T143763
Change-Id: Iad63e8866eeccf316b3efe3a44888256c0c407d8
This commit is contained in:
Roan Kattouw 2016-08-23 19:22:01 -07:00
parent 4e99a5095f
commit ce3d6b2f49
2 changed files with 0 additions and 96 deletions

View file

@ -57,70 +57,6 @@ class EchoEventMapper extends EchoAbstractMapper {
return EchoEvent::newFromRow( $row );
}
/**
* Get a list of echo events identified by user and bundle hash
*
* @param $user User
* @param $bundleHash string the bundle hash
* @param $distributionType string distribution medium: 'web' or 'email'
* @param $order string 'ASC'/'DESC'
* @param $limit int
* @return EchoEvent[]
*/
public function fetchByUserBundleHash( User $user, $bundleHash, $distributionType = 'web', $order = 'DESC', $limit = 250 ) {
$dbr = $this->dbFactory->getEchoDb( DB_SLAVE );
// We only display 99+ if the number is over 100, we can do limit 250, this should
// be sufficient to return 99 distinct group iterators, avoid select count( distinct )
// for the following reason:
// 1. it will not scale for large volume data
// 2. notification may have random grouping iterator
// 3. agent may be anonymous, can't do distinct over two columns: event_agent_id and event_agent_ip
// TODO: the 'web' branch shouldn't be used anymore. the 'email' branch wo't be needed once the html email formatter is merged
if ( $distributionType == 'web' ) {
$res = $dbr->select(
array( 'echo_notification', 'echo_event' ),
array( 'event_agent_id', 'event_agent_ip', 'event_extra',
'event_id', 'event_page_id', 'event_type', 'event_variant',
'notification_timestamp' ),
array(
'notification_event=event_id',
'notification_user' => $user->getId(),
'notification_bundle_base' => 0,
'notification_bundle_display_hash' => $bundleHash
),
__METHOD__,
array( 'ORDER BY' => 'notification_timestamp ' . $order, 'LIMIT' => $limit )
);
// this would be email for now
} else {
$res = $dbr->select(
array( 'echo_email_batch', 'echo_event' ),
array( 'event_agent_id', 'event_agent_ip', 'event_extra',
'event_id', 'event_page_id', 'event_type', 'event_variant', 'event_deleted' ),
array(
'eeb_event_id=event_id',
'eeb_user_id' => $user->getId(),
'eeb_event_hash' => $bundleHash
),
__METHOD__,
array( 'ORDER BY' => 'eeb_event_id ' . $order, 'LIMIT' => $limit )
);
}
$data = array();
foreach ( $res as $row ) {
$event = EchoEvent::newFromRow( $row );
if ( $event ) {
$data[] = $event;
}
}
return $data;
}
/**
* @param int[] $eventIds
* @param bool $deleted

View file

@ -70,38 +70,6 @@ class EchoEventMapperTest extends MediaWikiTestCase {
$this->assertInstanceOf( 'EchoEvent', $res );
}
public function testFetchByUserBundleHash() {
// Successful select
$dbResult = array(
(object)array(
'event_id' => 1,
'event_type' => 'test',
'event_variant' => '',
'event_extra' => '',
'event_page_id' => '',
'event_agent_id' => '',
'event_agent_ip' => '',
'event_deleted' => 0,
),
(object)array(
'event_id' => 2,
'event_type' => 'test2',
'event_variant' => '',
'event_extra' => '',
'event_page_id' => '',
'event_agent_id' => '',
'event_agent_ip' => '',
'event_deleted' => 0,
)
);
$eventMapper = new EchoEventMapper( $this->mockMWEchoDbFactory( array( 'select' => $dbResult ) ) );
$res = $eventMapper->fetchByUserBundleHash( User::newFromId( 1 ), 'testhash', 'web', 'DESC', 250 );
$this->assertTrue( is_array( $res ) );
foreach ( $res as $row ) {
$this->assertInstanceOf( 'EchoEvent', $row );
}
}
/**
* Mock object of EchoEvent
*/