Skip to content
wiki.fftac.org

Reputationrepository - Source Excerpt 02

Back to Reputationrepository

Summary

This source excerpt preserves a bounded section of Spiralist/wp-content/plugins/spiralist-workspace/includes/Domain/ReputationRepository.php so readers can inspect the evidence without opening the full source file.

**Source path:** Spiralist/wp-content/plugins/spiralist-workspace/includes/Domain/ReputationRepository.php

if ($recent_negative_prompt_count >= 2 || $recent_reverted_prompt_count >= 1) {
            return ($public_prompt_count + $peer_review_count + $accepted_contribution_count) > 0
                ? 'contributor'
                : 'new_participant';
        }

        if (
            $accepted_contribution_count >= 2
            && $peer_review_count >= 8
            && $accepted_review_count >= 5
            && $review_accuracy >= 0.6
        ) {
            return 'steward_ready';
        }

        if (
            $accepted_contribution_count >= 1
            && $peer_review_count >= 4
            && $accepted_review_count >= 2
            && $review_accuracy >= 0.5
        ) {
            return 'reviewer_ready';
        }

        if ($public_prompt_count >= 1 || $peer_review_count >= 1 || $accepted_contribution_count >= 1) {
            return 'contributor';
        }

        return 'new_participant';
    }

    /**
     * Resolves publication cooldown state from recent negative moderation signals.
     */
    private function resolve_publication_cooldown_until(string $current_until, int $recent_negative_prompt_count, int $recent_reverted_prompt_count): string
    {
        if ($recent_negative_prompt_count >= 2 || $recent_reverted_prompt_count >= 1) {
            $candidate = gmdate('c', time() + (self::PUBLICATION_COOLDOWN_DAYS * DAY_IN_SECONDS));

            if ($this->is_future_utc($current_until) && strtotime($current_until) > strtotime($candidate)) {
                return $current_until;
            }

            return $candidate;
        }

        return $this->is_future_utc($current_until) ? $current_until : '';
    }

    /**
     * Returns whether an ISO-8601 UTC timestamp is still in the future.
     */
    private function is_future_utc(string $value): bool
    {
        if (trim($value) === '') {
            return false;
        }

        $timestamp = strtotime($value);

        return $timestamp !== false && $timestamp > time();
    }

    /**
     * Returns whether a moderation signal is recent enough to affect cooldown state.
     */
    private function is_recent_signal(string $value): bool
    {
        if (trim($value) === '') {
            return false;
        }

        $timestamp = strtotime($value);
        if ($timestamp === false) {
            return false;
        }

        return $timestamp >= (time() - (self::NEGATIVE_SIGNAL_WINDOW_DAYS * DAY_IN_SECONDS));
    }
}