forked from GNUsocial/gnu-social
Merge branch '1.0.x' of gitorious.org:statusnet/mainline into 1.0.x
* '1.0.x' of gitorious.org:statusnet/mainline: Show both empty and full notice search results inside event wrapper More interesting test notices in createsim.php
This commit is contained in:
commit
5454d22b79
@ -132,19 +132,19 @@ class NoticesearchAction extends SearchAction
|
|||||||
*/
|
*/
|
||||||
function showResults($q, $page)
|
function showResults($q, $page)
|
||||||
{
|
{
|
||||||
if ($this->notice->N === 0) {
|
|
||||||
$this->showEmptyResults($q, $page);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Event::handle('StartNoticeSearchShowResults', array($this, $q, $this->notice))) {
|
if (Event::handle('StartNoticeSearchShowResults', array($this, $q, $this->notice))) {
|
||||||
$terms = preg_split('/[\s,]+/', $q);
|
if ($this->notice->N === 0) {
|
||||||
$nl = new SearchNoticeList($this->notice, $this, $terms);
|
$this->showEmptyResults($q, $page);
|
||||||
$cnt = $nl->show();
|
} else {
|
||||||
$this->pagination($page > 1,
|
$terms = preg_split('/[\s,]+/', $q);
|
||||||
$cnt > NOTICES_PER_PAGE,
|
$nl = new SearchNoticeList($this->notice, $this, $terms);
|
||||||
$page,
|
$cnt = $nl->show();
|
||||||
'noticesearch',
|
$this->pagination($page > 1,
|
||||||
array('q' => $q));
|
$cnt > NOTICES_PER_PAGE,
|
||||||
|
$page,
|
||||||
|
'noticesearch',
|
||||||
|
array('q' => $q));
|
||||||
|
}
|
||||||
Event::handle('EndNoticeSearchShowResults', array($this, $q, $this->notice));
|
Event::handle('EndNoticeSearchShowResults', array($this, $q, $this->notice));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ Creates a lot of test users and notices to (loosely) simulate a real server.
|
|||||||
-j --joins Number of groups per user (default 5)
|
-j --joins Number of groups per user (default 5)
|
||||||
-t --tags Number of distinct hash tags (default 10000)
|
-t --tags Number of distinct hash tags (default 10000)
|
||||||
-x --prefix User name prefix (default 'testuser')
|
-x --prefix User name prefix (default 'testuser')
|
||||||
|
-w --words Words file (default '/usr/share/dict/words')
|
||||||
|
|
||||||
END_OF_CREATESIM_HELP;
|
END_OF_CREATESIM_HELP;
|
||||||
|
|
||||||
@ -78,7 +79,7 @@ function newNotice($i, $tagmax)
|
|||||||
|
|
||||||
$is_reply = rand(0, 1);
|
$is_reply = rand(0, 1);
|
||||||
|
|
||||||
$content = 'Test notice content';
|
$content = testNoticeContent();
|
||||||
|
|
||||||
if ($is_reply == 0) {
|
if ($is_reply == 0) {
|
||||||
$stream = new InboxNoticeStream($user, $user->getProfile());
|
$stream = new InboxNoticeStream($user, $user->getProfile());
|
||||||
@ -206,6 +207,31 @@ function newJoin($u, $g)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testNoticeContent()
|
||||||
|
{
|
||||||
|
global $words;
|
||||||
|
|
||||||
|
if (is_null($words)) {
|
||||||
|
return "test notice content";
|
||||||
|
}
|
||||||
|
|
||||||
|
$cnt = rand(3, 8);
|
||||||
|
|
||||||
|
$ids = array_rand($words, $cnt);
|
||||||
|
|
||||||
|
foreach ($ids as $id) {
|
||||||
|
$parts[] = $words[$id];
|
||||||
|
}
|
||||||
|
|
||||||
|
$text = implode(' ', $parts);
|
||||||
|
|
||||||
|
if (mb_strlen($text) > 80) {
|
||||||
|
$text = substr($text, 0, 77) . "...";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
function main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $tagmax)
|
function main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $tagmax)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
@ -282,6 +308,13 @@ $joinsavg = (have_option('j', 'joins')) ? get_option_value('j', 'joins') : 5;
|
|||||||
$tagmax = (have_option('t', 'tags')) ? get_option_value('t', 'tags') : 10000;
|
$tagmax = (have_option('t', 'tags')) ? get_option_value('t', 'tags') : 10000;
|
||||||
$userprefix = (have_option('x', 'prefix')) ? get_option_value('x', 'prefix') : 'testuser';
|
$userprefix = (have_option('x', 'prefix')) ? get_option_value('x', 'prefix') : 'testuser';
|
||||||
$groupprefix = (have_option('z', 'groupprefix')) ? get_option_value('z', 'groupprefix') : 'testgroup';
|
$groupprefix = (have_option('z', 'groupprefix')) ? get_option_value('z', 'groupprefix') : 'testgroup';
|
||||||
|
$wordsfile = (have_option('w', 'words')) ? get_option_value('w', 'words') : '/usr/share/dict/words';
|
||||||
|
|
||||||
|
if (is_readable($wordsfile)) {
|
||||||
|
$words = file($wordsfile);
|
||||||
|
} else {
|
||||||
|
$words = null;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $tagmax);
|
main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $tagmax);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user