<commit_before><?php

/**
 * Handling the Payment Postprocessing
 * 
 * This Crontroller handles the Postprocessing of the transactions after they have been confirmed by the provider
 * 
 * TODO: Add a warning message to the DB instead of existing directly
 * 
 * @author <NAME>
 * @copyright (c) 2014, <NAME>
 */
class PaymentQueueWorker
{

    public function fire($job, $data)
    {
        $transaction_id = $data["transaction"];

        Log::info("Queue Worker Fired");
        Log::info("Transaction-ID: " . $transaction_id);

        //Get the transaction from the db
        $transaction = SDPaymentTransaction::find($transaction_id);
        if (!$transaction)
        {
            Log::warning("Could not load Transaction from Database");
            exit();
        }
        if ($transaction->status != "confirmed")
        {
            Log::error("Transaction" . $transaction->id . "not confirmed - aborting");
        }

        Log::info("Transaction loaded from DB");
        Log::info("Transaction user_id: " . $transaction->user_id);
        Log::info("Transaction payment provider: " . $transaction->payment_provider);
        Log::info("Transaction Items: " . $transaction->items);

        //Get the user from the DB
        $user = Sentinel::findById($transaction->user_id);
        if (!$user)
        {
            Log::error("Could not find the user " . $transaction->user_id . " in the DB");
            exit();
        }

        //Get the transaction items
        $trans_items = json_decode($transaction->items);
        if ($trans_items == false)
        {
            Log::error("Invalid Item JSON at the Transaction " . $transaction->id);
            exit();
        }

        //Get the User info from the DB
        $user_infos = SDUserinfo::where("user_id", $transaction->user_id);
        if (!$user_infos)
        {
            Log::error("Could not get the User Infos from the db for transaction: " . $transaction->id);
            exit();
        }

        //Go through the items and assign them to the user
        foreach ($trans_items as $trans_item)
        {
            Log::info("Got Trans Item id:" . $trans_item->id);
            Log::info("Got Trans Item count:" . $trans_item->count);

            //Get the item info from the db
            $item = SDItem::find($trans_item->id);
            if (!$item)
            {
                Log::error("Could not get SD Item with id " . $trans_item->id . " from the DB");
                exit();
            }
            Log::info("Got SDItem: " . $item->id . " - " . $item->name_short);

            //Get the handlers for the item and call them
            $handlers = json_decode($item->handlers);
            if ($handlers == false)
            {
                Log::error("Invalid Handler JSON at Item: " . $item->id);
            }

            //Call the item multiple times according to the item count
            for ($i = 1; $i = $trans_item->count; $i++)
            {
                foreach ($handlers as $handler)
                {
                    Log::info("Got Handler Class: " . $handler->class);
                    Log::info("Got Handler Params " . var_dump($handler->params));

                    $item_handler = new $handler->class;

                    //$item_handler->add_item($user, $user_infos, $handler->params);
                }
            }
        }


        //Update the User in the DB
        //Check for errors
    }

}
<commit_msg>Updated the queue worker<commit_after><?php

/**
 * Handling the Payment Postprocessing
 * 
 * This Crontroller handles the Postprocessing of the transactions after they have been confirmed by the provider
 * 
 * TODO: Add a warning message to the DB instead of existing directly
 * 
 * @author <NAME>
 * @copyright (c) 2014, <NAME>
 */
class PaymentQueueWorker
{

    public function fire($job, $data)
    {
        $transaction_id = $data["transaction"];

        Log::info("Queue Worker Fired");
        Log::info("Transaction-ID: " . $transaction_id);

        //Get the transaction from the db
        $transaction = SDPaymentTransaction::find($transaction_id);
        if (!$transaction)
        {
            Log::warning("Could not load Transaction from Database");
            exit();
        }
        if ($transaction->status != "confirmed")
        {
            Log::error("Transaction" . $transaction->id . "not confirmed - aborting");
        }

        Log::info("Transaction loaded from DB");
        Log::info("Transaction user_id: " . $transaction->user_id);
        Log::info("Transaction payment provider: " . $transaction->payment_provider);
        Log::info("Transaction Items: " . $transaction->items);

        //Get the user from the DB
        $user = Sentinel::findById($transaction->user_id);
        if (!$user)
        {
            Log::error("Could not find the user " . $transaction->user_id . " in the DB");
            exit();
        }

        //Get the transaction items
        $trans_items = json_decode($transaction->items);
        if ($trans_items == false)
        {
            Log::error("Invalid Item JSON at the Transaction " . $transaction->id);
            exit();
        }

        //Get the User info from the DB
        $user_infos = SDUserinfo::where("user_id", $transaction->user_id);
        if (!$user_infos)
        {
            Log::error("Could not get the User Infos from the db for transaction: " . $transaction->id);
            exit();
        }

        //Go through the items and assign them to the user
        foreach ($trans_items as $trans_item)
        {
            Log::info("Got Trans Item id:" . $trans_item->id);
            Log::info("Got Trans Item count:" . $trans_item->count);

            //Get the item info from the db
            $item = SDItem::find($trans_item->id);
            if (!$item)
            {
                Log::error("Could not get SD Item with id " . $trans_item->id . " from the DB");
                exit();
            }
            Log::info("Got SDItem: " . $item->id . " - " . $item->name_short);

            //Get the handlers for the item and call them
            $handlers = json_decode($item->handlers);
            if ($handlers == false)
            {
                Log::error("Invalid Handler JSON at Item: " . $item->id);
            }

            //Call the item multiple times according to the item count
            for ($i = 1; $i == $trans_item->count; $i++)
            {
                foreach ($handlers as $handler)
                {
                    Log::info("Got Handler Class: " . $handler->class);
                    Log::info("Got Handler Params " . var_dump($handler->params));

                    $item_handler = new $handler->class;

                    //$item_handler->add_item($user, $user_infos, $handler->params);
                }
            }
        }


        //Update the User in the DB
        //Check for errors
    }

}

{'fraction_non_alphanumeric': 0.12949123311296348, 'fraction_numerical': 0.0014371945961483186, 'mean_word_length': 1.7992759452936444, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 57, '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': '649967', 'n_tokens_mistral': 1876, 'n_tokens_neox': 1795, 'n_words': 537}