summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/showstream.php2
-rw-r--r--classes/Notice.php6
-rw-r--r--classes/Profile.php37
-rw-r--r--lib/grouptagcloudsection.php21
-rw-r--r--scripts/setup.cfg.sample1
-rwxr-xr-xscripts/setup_status_network.sh6
6 files changed, 48 insertions, 25 deletions
diff --git a/actions/showstream.php b/actions/showstream.php
index 72316b259..cd5d4bb70 100644
--- a/actions/showstream.php
+++ b/actions/showstream.php
@@ -370,7 +370,7 @@ class ShowstreamAction extends ProfileAction
{
$notice = empty($this->tag)
? $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1)
- : $this->user->getTaggedNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null, $this->tag);
+ : $this->user->getTaggedNotices($this->tag, ($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null);
$pnl = new ProfileNoticeList($notice, $this);
$cnt = $pnl->show();
diff --git a/classes/Notice.php b/classes/Notice.php
index 18f3f654e..e621805df 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -379,6 +379,12 @@ class Notice extends Memcached_DataObject
if ($tag->find()) {
while ($tag->fetch()) {
$tag->blowCache($blowLast);
+ $ck = 'profile:notice_ids_tagged:' . $this->profile_id . ':' . $tag->tag;
+
+ $cache->delete($ck);
+ if ($blowLast) {
+ $cache->delete($ck . ';last');
+ }
}
}
$tag->free();
diff --git a/classes/Profile.php b/classes/Profile.php
index 4a459b974..2f432ae8e 100644
--- a/classes/Profile.php
+++ b/classes/Profile.php
@@ -153,18 +153,16 @@ class Profile extends Memcached_DataObject
return null;
}
- function getTaggedNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null, $tag=null)
+ function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0, $since=null)
{
- // XXX: I'm not sure this is going to be any faster. It probably isn't.
$ids = Notice::stream(array($this, '_streamTaggedDirect'),
- array(),
- 'profile:notice_ids:' . $this->id,
- $offset, $limit, $since_id, $before_id, $since, $tag);
- common_debug(print_r($ids, true));
+ array($tag),
+ 'profile:notice_ids_tagged:' . $this->id . ':' . $tag,
+ $offset, $limit, $since_id, $max_id, $since);
return Notice::getStreamByIds($ids);
}
- function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null)
+ function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0, $since=null)
{
// XXX: I'm not sure this is going to be any faster. It probably isn't.
$ids = Notice::stream(array($this, '_streamDirect'),
@@ -175,18 +173,23 @@ class Profile extends Memcached_DataObject
return Notice::getStreamByIds($ids);
}
- function _streamTaggedDirect($offset, $limit, $since_id, $before_id, $since=null, $tag=null)
+ function _streamTaggedDirect($tag, $offset, $limit, $since_id, $max_id, $since)
{
- common_debug('_streamTaggedDirect()');
+ // XXX It would be nice to do this without a join
+
$notice = new Notice();
- $notice->profile_id = $this->id;
- $query = "select id from notice join notice_tag on id=notice_id where tag='" . $notice->escape($tag) . "' and profile_id=" . $notice->escape($notice->profile_id);
+
+ $query =
+ "select id from notice join notice_tag on id=notice_id where tag='".
+ $notice->escape($tag) .
+ "' and profile_id=" . $notice->escape($this->id);
+
if ($since_id != 0) {
$query .= " and id > $since_id";
}
- if ($before_id != 0) {
- $query .= " and id < $before_id";
+ if ($max_id != 0) {
+ $query .= " and id < $max_id";
}
if (!is_null($since)) {
@@ -198,21 +201,19 @@ class Profile extends Memcached_DataObject
if (!is_null($offset)) {
$query .= " limit $offset, $limit";
}
+
$notice->query($query);
+
$ids = array();
while ($notice->fetch()) {
- common_debug(print_r($notice, true));
$ids[] = $notice->id;
}
return $ids;
}
-
-
-
- function _streamDirect($offset, $limit, $since_id, $before_id, $since = null)
+ function _streamDirect($offset, $limit, $since_id, $max_id, $since = null)
{
$notice = new Notice();
diff --git a/lib/grouptagcloudsection.php b/lib/grouptagcloudsection.php
index 5d68af28b..9b7a10f6b 100644
--- a/lib/grouptagcloudsection.php
+++ b/lib/grouptagcloudsection.php
@@ -32,7 +32,7 @@ if (!defined('LACONICA')) {
}
/**
- * Personal tag cloud section
+ * Group tag cloud section
*
* @category Widget
* @package Laconica
@@ -64,12 +64,27 @@ class GroupTagCloudSection extends TagCloudSection
$weightexpr='sum(exp(-(now() - notice_tag.created) / %s))';
}
+ $names = $this->group->getAliases();
+
+ $names = array_merge(array($this->group->nickname), $names);
+
+ // XXX This is dumb.
+
+ $quoted = array();
+
+ foreach ($names as $name) {
+ $quoted[] = "\"$name\"";
+ }
+
+ $namestring = implode(',', $quoted);
+
$qry = 'SELECT notice_tag.tag, '.
$weightexpr . ' as weight ' .
'FROM notice_tag JOIN notice ' .
'ON notice_tag.notice_id = notice.id ' .
'JOIN group_inbox on group_inbox.notice_id = notice.id ' .
'WHERE group_inbox.group_id = %d ' .
+ 'AND notice_tag.tag not in (%s) '.
'GROUP BY notice_tag.tag ' .
'ORDER BY weight DESC ';
@@ -85,9 +100,9 @@ class GroupTagCloudSection extends TagCloudSection
$tag = Memcached_DataObject::cachedQuery('Notice_tag',
sprintf($qry,
common_config('tag', 'dropoff'),
- $this->group->id),
+ $this->group->id,
+ $namestring),
3600);
return $tag;
}
-
}
diff --git a/scripts/setup.cfg.sample b/scripts/setup.cfg.sample
index 4194bc146..450b9c30a 100644
--- a/scripts/setup.cfg.sample
+++ b/scripts/setup.cfg.sample
@@ -2,6 +2,7 @@
# Base database name; full name will include nickname
+export DBHOST=masterdb.example.net
export DBBASE=_example_net
export USERBASE=_example_net
export ADMIN=root
diff --git a/scripts/setup_status_network.sh b/scripts/setup_status_network.sh
index d80612b94..e1d14593f 100755
--- a/scripts/setup_status_network.sh
+++ b/scripts/setup_status_network.sh
@@ -11,13 +11,13 @@ export username=$nickname$USERBASE
# Create the db
-mysqladmin -u $ADMIN --password=$ADMINPASS create $database
+mysqladmin -h $DBHOST -u $ADMIN --password=$ADMINPASS create $database
for f in laconica.sql sms_carrier.sql foreign_services.sql notice_source.sql; do
- mysql -u $ADMIN --password=$ADMINPASS $database < ../db/$f;
+ mysql -h $DBHOST -u $ADMIN --password=$ADMINPASS $database < ../db/$f;
done
-mysql -u $ADMIN --password=$ADMINPASS $SITEDB << ENDOFCOMMANDS
+mysql -h $DBHOST -u $ADMIN --password=$ADMINPASS $SITEDB << ENDOFCOMMANDS
GRANT INSERT,SELECT,UPDATE,DELETE ON $database.* TO '$username'@'localhost' IDENTIFIED BY '$password';
GRANT INSERT,SELECT,UPDATE,DELETE ON $database.* TO '$username'@'%' IDENTIFIED BY '$password';