Skip to content

Commit

Permalink
getProjectsChangedSince()
Browse files Browse the repository at this point in the history
New method to get a list of firehose projects that have changed
since a particular timestamp.
  • Loading branch information
jamiemccarthy committed Sep 16, 2008
1 parent 5aab147 commit 403b29c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
30 changes: 28 additions & 2 deletions Slash/DB/MySQL/MySQL.pm
Expand Up @@ -12264,11 +12264,17 @@ sub addGlobjEssentialsToHashrefArray {

my %data = ( );

$self->_addGlobjEssentials_stories($ar, \%data);
$self->_addGlobjEssentials_urls($ar, \%data);
# Some of these are not written (yet).
$self->_addGlobjEssentials_submissions($ar, \%data);
$self->_addGlobjEssentials_journals($ar, \%data);
$self->_addGlobjEssentials_urls($ar, \%data);
# $self->_addGlobjEssentials_feeds($ar, \%data);
$self->_addGlobjEssentials_stories($ar, \%data);
# $self->_addGlobjEssentials_vendors($ar, \%data);
# $self->_addGlobjEssentials_miscs($ar, \%data);
$self->_addGlobjEssentials_comments($ar, \%data);
# $self->_addGlobjEssentials_discussions($ar, \%data);
$self->_addGlobjEssentials_projects($ar, \%data);

# Scan over the arrayref and insert the information from %data
# for each object.
Expand Down Expand Up @@ -12410,6 +12416,26 @@ sub _addGlobjEssentials_comments {
}
}

sub _addGlobjEssentials_projects {
my($self, $ar, $data_hr) = @_;
my $constants = getCurrentStatic();
my $projects_hr = _addGlobjEssentials_getids($ar, 'projects');
my @project_ids = sort { $a <=> $b } keys %$projects_hr;
my $id_str = join(',', @project_ids);
my $projectdata_hr = $id_str
? $self->sqlSelectAllHashref('id',
'id, url, textname, createtime',
'projects, urls',
"id IN ($id_str) AND projects.url_id=urls.url_id");
: { };
for my $id (@project_ids) {
my $globjid = $projects_hr->{$cid};
$data_hr->{$globjid}{url} = $projectdata_hr->{$id}{url};
$data_hr->{$globjid}{title} = $projectdata_hr->{$id}{textname};
$data_hr->{$globjid}{created_at} = $projectdata_hr->{$id}{createtime};
}
}

# Returns a hashref in which the keys are either numeric clid's OR
# the names of clout types, and the values are the opposite. So if
# the clid_types table is the row (1, 'vote', 'Slash::Foo'),
Expand Down
19 changes: 19 additions & 0 deletions plugins/FireHose/FireHose.pm
Expand Up @@ -3245,6 +3245,25 @@ sub setSkinVolume {
my($self, $data) = @_;
$self->sqlReplace("firehose_skin_volume", $data);
}

sub getProjectsChangedSince {
my($self, $ts, $options) = @_;
my $ts_q = $self->sqlQuote($ts);
my $max_num = defined($options->{max_num}) ? $options->{max_num} : 10;

my $hr_ar = $self->sqlSelectAllHashrefArray(
'firehose.id, firehose.globjid, firehose.toptags',
'firehose, discussions',
"firehose.type='project'
AND firehose.discussion = discussions.id
AND (firehose.last_update >= $ts_q OR discussions.last_update >= $ts_q)",
"ORDER BY GREATEST(firehose.last_update, discussions.last_update) DESC
LIMIT $max_num");
$self->addGlobjEssentialsToHashrefArray($hr_ar);

return $hr_ar;
}

1;

__END__
Expand Down

0 comments on commit 403b29c

Please sign in to comment.