function testUser($filter, $user) { printfnq("Testing user %s\n", $user->nickname); $profile = Profile::getKV('id', $user->id); $str = new ProfileNoticeStream($profile, $profile); $offset = 0; $limit = 100; do { $notice = $str->getNotices($offset, $limit); while ($notice->fetch()) { try { printfv("Testing notice %d...", $notice->id); $result = $filter->test($notice); Spam_score::save($notice, $result); printfv("%s\n", $result->isSpam ? "SPAM" : "HAM"); } catch (Exception $e) { printfnq("ERROR testing notice %d: %s\n", $notice->id, $e->getMessage()); } } $offset += $notice->N; } while ($notice->N > 0); }
function dumpNotices($user, $dir) { common_log(LOG_INFO, 'dumping notices by ' . $user->nickname . ' to directory ' . $dir); $profile = $user->getProfile(); $stream = new ProfileNoticeStream($profile, $profile); $page = 1; do { $notice = $stream->getNotices(($page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); while ($notice->fetch()) { try { $fname = $dir . '/' . common_date_iso8601($notice->created) . '-notice-' . $notice->id . '.atom'; $data = $notice->asAtomEntry(false, false, false, null); common_log(LOG_INFO, 'dumping notice ' . $notice->id . ' to file ' . $fname); file_put_contents($fname, $data); $data = null; } catch (Exception $e) { common_log(LOG_ERR, "Error backing up notice " . $notice->id . ": " . $e->getMessage()); continue; } } $page++; } while ($notice->N > NOTICES_PER_PAGE); }
function getNotices($offset = 0, $limit = NOTICES_PER_PAGE, $since_id = 0, $max_id = 0, Profile $scoped = null) { $stream = new ProfileNoticeStream($this, $scoped); return $stream->getNotices($offset, $limit, $since_id, $max_id); }