Annihilate profile_tag_inbox.
This commit is contained in:
parent
3550afb5f0
commit
22f6151a10
|
@ -33,7 +33,7 @@ require_once INSTALLDIR.'/lib/feedlist.php';
|
|||
|
||||
class ShowprofiletagAction extends Action
|
||||
{
|
||||
var $notice, $tagger, $peopletag;
|
||||
var $notice, $tagger, $peopletag, $userProfile;
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
|
@ -88,7 +88,12 @@ class ShowprofiletagAction extends Action
|
|||
}
|
||||
|
||||
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
||||
$this->notice = $this->peopletag->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
|
||||
$this->userProfile = Profile::current();
|
||||
|
||||
$stream = new PeopletagNoticeStream($this->peopletag, $this->userProfile);
|
||||
|
||||
$this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
|
||||
NOTICES_PER_PAGE + 1);
|
||||
|
||||
if ($this->page > 1 && $this->notice->N == 0) {
|
||||
// TRANS: Server error when page not found (404).
|
||||
|
@ -239,7 +244,7 @@ class ShowprofiletagAction extends Action
|
|||
function showNotices()
|
||||
{
|
||||
if (Event::handle('StartShowProfileTagContent', array($this))) {
|
||||
$nl = new NoticeList($this->notice, $this);
|
||||
$nl = new ThreadedNoticeList($this->notice, $this, $this->userProfile);
|
||||
|
||||
$cnt = $nl->show();
|
||||
|
||||
|
@ -247,10 +252,12 @@ class ShowprofiletagAction extends Action
|
|||
$this->showEmptyListMessage();
|
||||
}
|
||||
|
||||
$this->pagination(
|
||||
$this->page > 1, $cnt > NOTICES_PER_PAGE,
|
||||
$this->page, 'showprofiletag', array('tag' => $this->peopletag->tag,
|
||||
'tagger' => $this->tagger->nickname)
|
||||
$this->pagination($this->page > 1,
|
||||
$cnt > NOTICES_PER_PAGE,
|
||||
$this->page,
|
||||
'showprofiletag',
|
||||
array('tag' => $this->peopletag->tag,
|
||||
'tagger' => $this->tagger->nickname)
|
||||
);
|
||||
|
||||
Event::handle('EndShowProfileTagContent', array($this));
|
||||
|
|
|
@ -545,12 +545,6 @@ class Notice extends Memcached_DataObject
|
|||
|
||||
$notice->saveKnownGroups($groups);
|
||||
|
||||
if (isset($peopletags)) {
|
||||
$notice->saveProfileTags($peopletags);
|
||||
} else {
|
||||
$notice->saveProfileTags();
|
||||
}
|
||||
|
||||
if (isset($urls)) {
|
||||
$notice->saveKnownUrls($urls);
|
||||
} else {
|
||||
|
@ -596,6 +590,11 @@ class Notice extends Memcached_DataObject
|
|||
if (!empty($profile)) {
|
||||
$profile->blowNoticeCount();
|
||||
}
|
||||
|
||||
$ptags = $this->getProfileTags();
|
||||
foreach ($ptags as $ptag) {
|
||||
$ptag->blowNoticeStreamCache();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -618,6 +617,11 @@ class Notice extends Memcached_DataObject
|
|||
// In case we're the first, will need to calc a new root.
|
||||
self::blow('notice:conversation_root:%d', $this->conversation);
|
||||
}
|
||||
|
||||
$ptags = $this->getProfileTags();
|
||||
foreach ($ptags as $ptag) {
|
||||
$ptag->blowNoticeStreamCache(true);
|
||||
}
|
||||
}
|
||||
|
||||
/** save all urls in the notice to the db
|
||||
|
@ -1030,34 +1034,14 @@ class Notice extends Memcached_DataObject
|
|||
|
||||
function getProfileTags()
|
||||
{
|
||||
// Don't save ptags for repeats, for now.
|
||||
$profile = $this->getProfile();
|
||||
$list = $profile->getOtherTags($profile);
|
||||
$ptags = array();
|
||||
|
||||
if (!empty($this->repeat_of)) {
|
||||
return array();
|
||||
while($list->fetch()) {
|
||||
$ptags[] = clone($list);
|
||||
}
|
||||
|
||||
// XXX: cache me
|
||||
|
||||
$ptags = array();
|
||||
|
||||
$ptagi = new Profile_tag_inbox();
|
||||
|
||||
$ptagi->selectAdd();
|
||||
$ptagi->selectAdd('profile_tag_id');
|
||||
|
||||
$ptagi->notice_id = $this->id;
|
||||
|
||||
if ($ptagi->find()) {
|
||||
while ($ptagi->fetch()) {
|
||||
$profile_list = Profile_list::staticGet('id', $ptagi->profile_tag_id);
|
||||
if ($profile_list) {
|
||||
$ptags[] = $profile_list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ptagi->free();
|
||||
|
||||
return $ptags;
|
||||
}
|
||||
|
||||
|
@ -1173,72 +1157,6 @@ class Notice extends Memcached_DataObject
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* record targets into profile_tag_inbox.
|
||||
* @return array of Profile_list objects
|
||||
*/
|
||||
function saveProfileTags($known=array())
|
||||
{
|
||||
// Don't save ptags for repeats, for now
|
||||
|
||||
if (!empty($this->repeat_of)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if (is_array($known)) {
|
||||
$ptags = $known;
|
||||
} else {
|
||||
$ptags = array();
|
||||
}
|
||||
|
||||
$ptag = new Profile_tag();
|
||||
$ptag->tagged = $this->profile_id;
|
||||
|
||||
if($ptag->find()) {
|
||||
while($ptag->fetch()) {
|
||||
$plist = Profile_list::getByTaggerAndTag($ptag->tagger, $ptag->tag);
|
||||
if (!empty($plist)) {
|
||||
$ptags[] = clone($plist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($ptags as $target) {
|
||||
$this->addToProfileTagInbox($target);
|
||||
}
|
||||
|
||||
return $ptags;
|
||||
}
|
||||
|
||||
function addToProfileTagInbox($plist)
|
||||
{
|
||||
$ptagi = Profile_tag_inbox::pkeyGet(array('profile_tag_id' => $plist->id,
|
||||
'notice_id' => $this->id));
|
||||
|
||||
if (empty($ptagi)) {
|
||||
|
||||
$ptagi = new Profile_tag_inbox();
|
||||
|
||||
$ptagi->query('BEGIN');
|
||||
$ptagi->profile_tag_id = $plist->id;
|
||||
$ptagi->notice_id = $this->id;
|
||||
$ptagi->created = $this->created;
|
||||
|
||||
$result = $ptagi->insert();
|
||||
if (!$result) {
|
||||
common_log_db_error($ptagi, 'INSERT', __FILE__);
|
||||
// TRANS: Server exception thrown when saving profile_tag inbox fails.
|
||||
throw new ServerException(_('Problem saving profile_tag inbox.'));
|
||||
}
|
||||
|
||||
$ptagi->query('COMMIT');
|
||||
|
||||
self::blow('profile_tag:notice_ids:%d', $ptagi->profile_tag_id);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save reply records indicating that this notice needs to be
|
||||
* delivered to the local users with the given URIs.
|
||||
|
|
|
@ -170,51 +170,6 @@ class Profile_list extends Memcached_DataObject
|
|||
return $stream->getNotices($offset, $limit, $since_id, $max_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query notices by users associated with this tag from the database.
|
||||
*
|
||||
* @param integer $offset offset
|
||||
* @param integer $limit maximum no of results
|
||||
* @param integer $since_id=null since this id
|
||||
* @param integer $max_id=null maximum id in result
|
||||
*
|
||||
* @return array array of notice ids.
|
||||
*/
|
||||
|
||||
function _streamDirect($offset, $limit, $since_id, $max_id)
|
||||
{
|
||||
$inbox = new Profile_tag_inbox();
|
||||
|
||||
$inbox->profile_tag_id = $this->id;
|
||||
|
||||
$inbox->selectAdd();
|
||||
$inbox->selectAdd('notice_id');
|
||||
|
||||
if ($since_id != 0) {
|
||||
$inbox->whereAdd('notice_id > ' . $since_id);
|
||||
}
|
||||
|
||||
if ($max_id != 0) {
|
||||
$inbox->whereAdd('notice_id <= ' . $max_id);
|
||||
}
|
||||
|
||||
$inbox->orderBy('notice_id DESC');
|
||||
|
||||
if (!is_null($offset)) {
|
||||
$inbox->limit($offset, $limit);
|
||||
}
|
||||
|
||||
$ids = array();
|
||||
|
||||
if ($inbox->find()) {
|
||||
while ($inbox->fetch()) {
|
||||
$ids[] = $inbox->notice_id;
|
||||
}
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get subscribers (local and remote) to this people tag
|
||||
* Order by reverse chronology
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Table Definition for profile_tag_inbox
|
||||
*/
|
||||
|
||||
class Profile_tag_inbox extends Memcached_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
/* the code below is auto generated do not remove the above tag */
|
||||
|
||||
public $__table = 'profile_tag_inbox'; // table name
|
||||
public $profile_tag_id; // int(4) primary_key not_null
|
||||
public $notice_id; // int(4) primary_key not_null
|
||||
public $created; // datetime() not_null
|
||||
|
||||
/* Static get */
|
||||
|
||||
function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Profile_tag_inbox',$k,$v); }
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
|
||||
function pkeyGet($kv)
|
||||
{
|
||||
return Memcached_DataObject::pkeyGet('Profile_tag_inbox', $kv);
|
||||
}
|
||||
}
|
|
@ -480,15 +480,6 @@ id = U
|
|||
tagger = K
|
||||
tag = K
|
||||
|
||||
[profile_tag_inbox]
|
||||
profile_tag_id = 129
|
||||
notice_id = 129
|
||||
created = 142
|
||||
|
||||
[profile_tag_inbox__keys]
|
||||
profile_tag_id = K
|
||||
notice_id = K
|
||||
|
||||
[profile_tag_subscription]
|
||||
profile_tag_id = 129
|
||||
profile_id = 129
|
||||
|
|
|
@ -11,6 +11,7 @@ id = profile:id
|
|||
[notice]
|
||||
profile_id = profile:id
|
||||
reply_to = notice:id
|
||||
profile_id = profile_tag:tagged
|
||||
|
||||
[reply]
|
||||
notice_id = notice:id
|
||||
|
@ -67,10 +68,6 @@ tagged = profile:id
|
|||
[profile_list]
|
||||
tagger = profile:id
|
||||
|
||||
[profile_tag_inbox]
|
||||
profile_tag_id = profile_list:id
|
||||
notice_id = notice:id
|
||||
|
||||
[profile_tag_subscription]
|
||||
profile_tag_id = profile_list:id
|
||||
profile_id = profile:id
|
||||
|
|
|
@ -71,36 +71,54 @@ class PeopletagNoticeStream extends ScopingNoticeStream
|
|||
*/
|
||||
class RawPeopletagNoticeStream extends NoticeStream
|
||||
{
|
||||
protected $profile_tag;
|
||||
protected $profile_list;
|
||||
|
||||
function __construct($profile_tag)
|
||||
function __construct($profile_list)
|
||||
{
|
||||
$this->profile_tag = $profile_tag;
|
||||
$this->profile_list = $profile_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query notices by users associated with this tag from the database.
|
||||
*
|
||||
* @param integer $offset offset
|
||||
* @param integer $limit maximum no of results
|
||||
* @param integer $since_id=null since this id
|
||||
* @param integer $max_id=null maximum id in result
|
||||
*
|
||||
* @return array array of notice ids.
|
||||
*/
|
||||
|
||||
function getNoticeIds($offset, $limit, $since_id, $max_id)
|
||||
{
|
||||
$inbox = new Profile_tag_inbox();
|
||||
$notice = new Notice();
|
||||
|
||||
$inbox->profile_tag_id = $this->profile_tag->id;
|
||||
$notice->selectAdd();
|
||||
$notice->selectAdd('notice.id');
|
||||
|
||||
$inbox->selectAdd();
|
||||
$inbox->selectAdd('notice_id');
|
||||
$ptag = new Profile_tag();
|
||||
$ptag->tag = $this->profile_list->tag;
|
||||
$ptag->tagger = $this->profile_list->tagger;
|
||||
$notice->joinAdd($ptag);
|
||||
|
||||
Notice::addWhereSinceId($inbox, $since_id, 'notice_id');
|
||||
Notice::addWhereMaxId($inbox, $max_id, 'notice_id');
|
||||
if ($since_id != 0) {
|
||||
$notice->whereAdd('notice.id > ' . $since_id);
|
||||
}
|
||||
|
||||
$inbox->orderBy('created DESC, notice_id DESC');
|
||||
if ($max_id != 0) {
|
||||
$notice->whereAdd('notice.id <= ' . $max_id);
|
||||
}
|
||||
|
||||
$notice->orderBy('notice.id DESC');
|
||||
|
||||
if (!is_null($offset)) {
|
||||
$inbox->limit($offset, $limit);
|
||||
$notice->limit($offset, $limit);
|
||||
}
|
||||
|
||||
$ids = array();
|
||||
|
||||
if ($inbox->find()) {
|
||||
while ($inbox->fetch()) {
|
||||
$ids[] = $inbox->notice_id;
|
||||
if ($notice->find()) {
|
||||
while ($notice->fetch()) {
|
||||
$ids[] = $notice->id;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user