queue or release newly-purchased GV's
191647
function update_credit_account($i) {
    global $db, $order, $insert_id;
    // only act on newly-purchased gift certificates
    if (preg_match('/^GIFT/', addslashes($order->products[$i]['model']))) {
      // determine how much GV was purchased
      $gv_order_amount = ($order->products[$i]['final_price'] * $order->products[$i]['qty']);
      // if tax is to be calculated on purchased GVs, calculate it
      if ($this->credit_tax=='true') $gv_order_amount = $gv_order_amount * (100 + $order->products[$i]['tax']) / 100;
      $gv_order_amount = $gv_order_amount * 100 / 100;

      if (MODULE_ORDER_TOTAL_GV_QUEUE == 'false') {
        // GV_QUEUE is false so release amount to account immediately
        $gv_result = $this->user_has_gv_account($_SESSION['customer_id']);
        $customer_gv = false;
        $total_gv_amount = 0;
        if ($gv_result) {
          $total_gv_amount = $gv_result;
          $customer_gv = true;
        }
        $total_gv_amount = $total_gv_amount + $gv_order_amount;
        if ($customer_gv) {
          $db->Execute("update " . TABLE_COUPON_GV_CUSTOMER . " set amount = '" . $total_gv_amount . "' where customer_id = '" . (int)$_SESSION['customer_id'] . "'");
        } else {
          $db->Execute("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . (int)$_SESSION['customer_id'] . "', '" . $total_gv_amount . "')");
        }
      } else {
        // GV_QUEUE is true - so queue the gv for release by store owner
        $db->Execute("insert into " . TABLE_COUPON_GV_QUEUE . " (customer_id, order_id, amount, date_created, ipaddr) values ('" . (int)$_SESSION['customer_id'] . "', '" . (int)$insert_id . "', '" . $gv_order_amount . "', NOW(), '" . $_SERVER['REMOTE_ADDR'] . "')");
      }
    }
  }
1233873
def purchase!(release_id, track_id, price, token, options={})
      warn "[DEPRECATION] `purchase!` is deprecated.  Please use 'purchase_item!' instead."
      purchase_item!(release_id, track_id, price, options={})
    end
166365
def RefreshClaims(self, ids, timeout="30m"):
    
    with data_store.DB.GetMutationPool() as mutation_pool:
      mutation_pool.QueueRefreshClaims(ids, timeout=timeout)
856792
def update_claim(self, queue, claim, ttl=None, grace=None):
        
        return queue.update_claim(claim, ttl=ttl, grace=grace)
1237456
private function gc()
    {
        // Whether to refresh the data
        $refresh = false;

        foreach (array_keys($this->arrayCache->getData()) as $key) {
            // Do remove outdated keys from the collection
            if ($this->arrayCache->isExpired($key, time())) {
                $refresh = true;
                $this->arrayCache->remove($key);
            }
        }

        if ($refresh === true) {
            // Explicit save with fresh data
            $this->write();
        }
    }
247294
function gotTotal(err, total, models) {
            opts.cb(err, models, {count: models.length, offset: offset, limit: limit, total: total});
        }
482597
def buy(self, account_id, **params):
        """"""
        if 'amount' not in params and 'total' not in params:
            raise ValueError("Missing required parameter: 'amount' or 'total'")
        for required in ['currency', 'payment_method']:
            if required not in params:
                raise ValueError("Missing required parameter: %s" % required)
        response = self._post('v2', 'accounts', account_id, 'buys', data=params)
        return self._make_api_object(response, Buy)
1223706
def confirm_paid(self, purchase_order_id, session, confirm_remark=None):
        ''''''
        request = TOPRequest('taobao.fenxiao.order.confirm.paid')
        request['purchase_order_id'] = purchase_order_id
        if confirm_remark!=None: request['confirm_remark'] = confirm_remark
        self.create(self.execute(request, session))
        return self.is_success
970226
def pack_req(cls, modify_order_op, order_id, price, qty,
                 adjust_limit, trd_env, acc_id, trd_mkt, conn_id):
        """"""
        from futuquant.common.pb.Trd_ModifyOrder_pb2 import Request
        req = Request()
        serial_no = get_unique_id32()
        req.c2s.packetID.serialNo = serial_no
        req.c2s.packetID.connID = conn_id

        req.c2s.header.trdEnv = TRD_ENV_MAP[trd_env]
        req.c2s.header.accID = acc_id
        req.c2s.header.trdMarket = TRD_MKT_MAP[trd_mkt]

        req.c2s.orderID = int(order_id)
        req.c2s.modifyOrderOp = MODIFY_ORDER_OP_MAP[modify_order_op]
        req.c2s.forAll = False

        if modify_order_op == ModifyOrderOp.NORMAL:
            req.c2s.qty = qty
            req.c2s.price = price
            req.c2s.adjustPrice = adjust_limit != 0
            req.c2s.adjustSideAndLimit = adjust_limit

        return pack_pb_req(req, ProtoId.Trd_ModifyOrder, conn_id, serial_no)
374492
def add_new(self, command):
        """"""
        self.queue[self.next_key] = command
        self.queue[self.next_key]['status'] = 'queued'
        self.queue[self.next_key]['returncode'] = ''
        self.queue[self.next_key]['stdout'] = ''
        self.queue[self.next_key]['stderr'] = ''
        self.queue[self.next_key]['start'] = ''
        self.queue[self.next_key]['end'] = ''

        self.next_key += 1
        self.write()
877279
def add(self, items):
        """"""
        for item in items:
            # Add the ack ID to the set of managed ack IDs, and increment
            # the size counter.
            if item.ack_id not in self._leased_messages:
                self._leased_messages[item.ack_id] = _LeasedMessage(
                    added_time=time.time(), size=item.byte_size
                )
                self._bytes += item.byte_size
            else:
                _LOGGER.debug("Message %s is already lease managed", item.ack_id)
841210
def sreenqueue(item_id, item_s, *args, **kwargs):
    '''
    '''
    return vsreenqueue(item_id, item_s, args, **kwargs)
1017782
def orders(self):
        
        self.account.refresh()
        return [o for o in self.account.openorders if self.bot["market"] == o.market and self.account.openorders]
433009
def _flush_queue(self, q, ignore_priority=False):
        
        assert isinstance(q, PriorityQueue)

        current_timestamp = compute_release_time(lag_in_minutes=0)
        for _ in range(len(q)):
            entry = q.pop()
            assert isinstance(entry, PriorityEntry)

            if ignore_priority or entry.release_time < current_timestamp:
                self._resubmit_uow(entry.entry)
            else:
                q.put(entry)
                break
1030253
def Copy(self):
    
    result = QueueManager(store=self.data_store, token=self.token)
    result.prev_frozen_timestamps = self.prev_frozen_timestamps
    result.frozen_timestamp = self.frozen_timestamp
    return result
1120000
function(id) {
        var q = queues[id];
        q.finished = true;

        if (q.aborted) {
            var msg = "transaction " + id + " was aborted";
            _fail(id, msg);
            return;
        }

        // execute success callback
        if (q.onSuccess) {
            var sc=q.scope || q.win;
            q.onSuccess.call(sc, _returnData(q));
        }
    }
657655
def releases(release_id=None, **kwargs):
    """"""
    if not 'id' in kwargs and release_id is not None:
        kwargs['release_id'] = release_id
        return Fred().release(**kwargs)
    return Fred().releases(**kwargs)