Skip to content

Commit

Permalink
Prepare for paramclout use in tag clout calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiemccarthy committed Feb 21, 2007
1 parent b346fa4 commit a8c9850
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 9 deletions.
36 changes: 27 additions & 9 deletions plugins/Tags/Tags.pm
Expand Up @@ -561,6 +561,7 @@ sub addCloutsToTagArrayref {
my($self, $ar) = @_;

return if !$ar || !@$ar;
my $constants = getCurrentStatic();

# Pull values from tag params named 'tag_clout'
my @tagids = sort { $a <=> $b } map { $_->{tagid} } @$ar;
Expand All @@ -581,19 +582,36 @@ sub addCloutsToTagArrayref {
my %uid = map { ($_->{uid}, 1) } @$ar;
my @uids = sort { $a <=> $b } keys %uid;
my $uids_in_str = join(',', @uids);
my $uid_info_hr = $self->sqlSelectAllHashref(
'uid',
'users.uid AS uid, seclev, karma, tag_clout',
'users, users_info',
"users.uid=users_info.uid AND users.uid IN ($uids_in_str)");
my $uid_info_hr;
my $clout_field = $constants->{tags_usecloutfield} || '';
if ($clout_field) {
$uid_info_hr = $self->sqlSelectAllHashref(
'uid',
'users.uid AS uid, seclev, karma, tag_clout, users_param.value AS paramclout',
"users,
users_info LEFT JOIN users_param
ON (users_info.uid=users_param.uid AND users_param.name='$clout_field')",
"users.uid=users_info.uid AND users.uid IN ($uids_in_str)");
} else {
$uid_info_hr = $self->sqlSelectAllHashref(
'uid',
'users.uid AS uid, seclev, karma, tag_clout',
'users, users_info',
"users.uid=users_info.uid AND users.uid IN ($uids_in_str)");
}
#print STDERR "uids_in_str='$uids_in_str'\n";

my $uid_clout_hr = { };
# XXX hardcoded formula, this should be parameterized at least with vars
for my $uid (keys %$uid_info_hr) {
$uid_clout_hr->{$uid} = $uid_info_hr->{$uid}{karma} >= -3 ? log($uid_info_hr->{$uid}{karma}+10) : 0;
$uid_clout_hr->{$uid} += 5 if $uid_info_hr->{$uid}{seclev} > 1;
$uid_clout_hr->{$uid} *= $uid_info_hr->{$uid}{tag_clout};
if (defined $uid_info_hr->{$uid}{paramclout}) {
$uid_clout_hr->{$uid} = $uid_info_hr->{$uid}{paramclout}
* $constants->{tags_usecloutfield_mult};
} else {
# XXX hardcoded formula, this should be parameterized at least with vars
$uid_clout_hr->{$uid} = $uid_info_hr->{$uid}{karma} >= -3 ? log($uid_info_hr->{$uid}{karma}+10) : 0;
$uid_clout_hr->{$uid} += 5 if $uid_info_hr->{$uid}{seclev} > 1;
$uid_clout_hr->{$uid} *= $uid_info_hr->{$uid}{tag_clout};
}
}

for my $tag_hr (@$ar) {
Expand Down
2 changes: 2 additions & 0 deletions plugins/Tags/mysql_dump.sql
Expand Up @@ -25,6 +25,8 @@ INSERT INTO vars (name, value, description) VALUES ('tags_urls_lastscanned', '0'
INSERT INTO vars (name, value, description) VALUES ('tags_urls_top_minscore', '2', 'Minimum score a tag must have to make it into the top tags for a urls');
INSERT INTO vars (name, value, description) VALUES ('tags_urls_pos_tags', 'plus', '| separated list of tags applied which positively affect url popularity');
INSERT INTO vars (name, value, description) VALUES ('tags_urls_neg_tags', 'minus|binspam', '| separated list of tags applied which negatively affect url popularity');
INSERT INTO vars (name, value, description) VALUES ('tags_usecloutfield', '', 'Use a users_param field for clout? Leave empty to use users_info.tag_clout times some simple multipliers');
INSERT INTO vars (name, value, description) VALUES ('tags_usecloutfield_mult', '1.0', 'Multiply the users_param field by this');
INSERT INTO vars (name, value, description) VALUES ('tags_userfrac_read', '1', 'Fraction (0.0-1.0) of user UIDs which are allowed to read tags, if tags_*_allow* is set that way');
INSERT INTO vars (name, value, description) VALUES ('tags_userfrac_write', '0.95', 'Fraction (0.0-1.0) of user UIDs which are allowed to tag, if tags_*_allow* is set that way');
INSERT INTO vars (name, value, description) VALUES ('tags_tagname_regex', '^\!?[a-z][a-z0-9/]{0,63}$', 'Regex that tag names must conform to');
Expand Down
10 changes: 10 additions & 0 deletions plugins/Tags/mysql_schema.sql
Expand Up @@ -118,3 +118,13 @@ CREATE TABLE tags_peerweight (
KEY gen_uid (gen, uid)
) TYPE=InnoDB;

CREATE TABLE tagnames_similar (
tsid int UNSIGNED NOT NULL AUTO_INCREMENT,
type smallint UNSIGNED NOT NULL DEFAULT '0',
src_tnid int UNSIGNED NOT NULL DEFAULT '0',
dest_tnid int UNSIGNED NOT NULL DEFAULT '0',
simil float NOT NULL DEFAULT '0',
PRIMARY KEY (tsid),
UNIQUE type_src_dest (type, src_tnid, dest_tnid)
) TYPE=InnoDB;

23 changes: 23 additions & 0 deletions sql/mysql/upgrades
Expand Up @@ -4406,5 +4406,28 @@ UPDATE vars SET value = 'T_2_5_0_147' WHERE name = 'cvs_tag_currentcode';

# SLASHCODE/USEPERL LAST UPDATED HERE

# 2007-02-14
UPDATE vars SET value = 'T_2_5_0_147' WHERE name = 'cvs_tag_currentcode';

# For plugins/FireHose
INSERT INTO firehose_tab VALUES (4,0,'User','"user:{nickname}"','createtime','DESC','black','full');
CREATE TABLE firehose_ogaspt (
globjid int(10) unsigned NOT NULL default '0',
pubtime datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (globjid)
) TYPE=InnoDB;

# For plugins/Tags
INSERT INTO vars (name, value, description) VALUES ('tags_usecloutfield', '', 'Use a users_param field for clout? Leave empty to use users_info.tag_clout times some simple multipliers');
INSERT INTO vars (name, value, description) VALUES ('tags_usecloutfield_mult', '1.0', 'Multiply the users_param field by this');
CREATE TABLE tagnames_similar (
tsid int UNSIGNED NOT NULL AUTO_INCREMENT,
type smallint UNSIGNED NOT NULL DEFAULT '0',
src_tnid int UNSIGNED NOT NULL DEFAULT '0',
dest_tnid int UNSIGNED NOT NULL DEFAULT '0',
simil float NOT NULL DEFAULT '0',
PRIMARY KEY (tsid),
UNIQUE type_src_dest (type, src_tnid, dest_tnid)
) TYPE=InnoDB;


0 comments on commit a8c9850

Please sign in to comment.