<commit_before><?php
namespace Minds\Helpers\Campaigns;

use Minds\Core;
use Minds\Helpers;
use Minds\Entities;

class EmailRewards
{
    public static function reward($campaign, $user_guid)
    {
        if (!is_numeric($user_guid)) {
            return;
        }

        $user = new Entities\User($user_guid);

        $cacher = Core\Data\cache\factory::build('apcu');

        switch ($campaign) {
          case "retention-1":
          case "retention-3":
          case "retention-7":
          case "retention-28":
            $points = 100;
            break;
          case "july-20-2016":
            $points = 1000;
            break;
          default:
            return;
        }

        if ($cacher->get("rewarded:email:$campaign:$user_guid") == true) {
            return;
        }

        $db = new Core\Data\Call('entities_by_time');
        $ts = Helpers\Analytics::buildTS("day", time());
        $row = $db->getRow("analytics:rewarded:email:$campaign", ['offset'=> $user_guid, 'limit'=>1]);
        if (!$row || key($row) != $user_guid) {
            $db->insert("analytics:rewarded:email:$campaign", [ $user_guid => time()]);

            Helpers\Wallet::createTransaction($user_guid, $points, $user_guid, "Email click. ($campaign)");
        }
        $cacher->set("rewarded:email:$campaign:$user_guid", true, strtotime('tomorrow', time()) - time());
    }
}
<commit_msg>(chore): change email reward key<commit_after><?php
namespace Minds\Helpers\Campaigns;

use Minds\Core;
use Minds\Helpers;
use Minds\Entities;

class EmailRewards
{
    public static function reward($campaign, $user_guid)
    {
        if (!is_numeric($user_guid)) {
            return;
        }

        $user = new Entities\User($user_guid);

        $cacher = Core\Data\cache\factory::build('apcu');

        switch ($campaign) {
          case "retention-1":
          case "retention-3":
          case "retention-7":
          case "retention-28":
            $points = 100;
            break;
          case "july-26-2016":
            $points = 1000;
            break;
          default:
            return;
        }

        if ($cacher->get("rewarded:email:$campaign:$user_guid") == true) {
            return;
        }

        $db = new Core\Data\Call('entities_by_time');
        $ts = Helpers\Analytics::buildTS("day", time());
        $row = $db->getRow("analytics:rewarded:email:$campaign", ['offset'=> $user_guid, 'limit'=>1]);
        if (!$row || key($row) != $user_guid) {
            $db->insert("analytics:rewarded:email:$campaign", [ $user_guid => time()]);

            Helpers\Wallet::createTransaction($user_guid, $points, $user_guid, "Email click. ($campaign)");
        }
        $cacher->set("rewarded:email:$campaign:$user_guid", true, strtotime('tomorrow', time()) - time());
    }
}

{'fraction_non_alphanumeric': 0.16566158212131962, 'fraction_numerical': 0.013479957431713374, 'mean_word_length': 2.2828870779976715, 'pattern_counts': {'":': 10, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '344973', 'n_tokens_mistral': 925, 'n_tokens_neox': 876, 'n_words': 158}