Add get_unmatched_bets_for_bettor() to get unmatched bets across all betting markets
This commit is contained in:
parent
05a06a6f6d
commit
f3290a8827
3 changed files with 63 additions and 45 deletions
|
|
@ -111,6 +111,7 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
|
|||
vector<betting_market_group_object> list_betting_market_groups(event_id_type) const;
|
||||
vector<betting_market_object> list_betting_markets(betting_market_group_id_type) const;
|
||||
vector<bet_object> get_unmatched_bets_for_bettor(betting_market_id_type, account_id_type) const;
|
||||
vector<bet_object> get_all_unmatched_bets_for_bettor(account_id_type) const;
|
||||
|
||||
// Markets / feeds
|
||||
vector<limit_order_object> get_limit_orders(asset_id_type a, asset_id_type b, uint32_t limit)const;
|
||||
|
|
@ -1077,7 +1078,18 @@ vector<bet_object> database_api::get_unmatched_bets_for_bettor(betting_market_id
|
|||
vector<bet_object> database_api_impl::get_unmatched_bets_for_bettor(betting_market_id_type betting_market_id, account_id_type bettor_id) const
|
||||
{
|
||||
const auto& bet_idx = _db.get_index_type<bet_object_index>().indices().get<by_bettor_and_odds>();
|
||||
return boost::copy_range<vector<bet_object> >(bet_idx.equal_range(std::make_tuple(betting_market_id, bettor_id)));
|
||||
return boost::copy_range<vector<bet_object> >(bet_idx.equal_range(std::make_tuple(bettor_id, betting_market_id)));
|
||||
}
|
||||
|
||||
vector<bet_object> database_api::get_all_unmatched_bets_for_bettor(account_id_type bettor_id) const
|
||||
{
|
||||
return my->get_all_unmatched_bets_for_bettor(bettor_id);
|
||||
}
|
||||
|
||||
vector<bet_object> database_api_impl::get_all_unmatched_bets_for_bettor(account_id_type bettor_id) const
|
||||
{
|
||||
const auto& bet_idx = _db.get_index_type<bet_object_index>().indices().get<by_bettor_and_odds>();
|
||||
return boost::copy_range<vector<bet_object> >(bet_idx.equal_range(std::make_tuple(bettor_id)));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -378,10 +378,15 @@ class database_api
|
|||
vector<betting_market_object> list_betting_markets(betting_market_group_id_type) const;
|
||||
|
||||
/**
|
||||
* @brief Return a list of all unmatched bets for a given account (includes bets on all markets)
|
||||
* @brief Return a list of all unmatched bets for a given account on a specific betting market
|
||||
*/
|
||||
vector<bet_object> get_unmatched_bets_for_bettor(betting_market_id_type, account_id_type) const;
|
||||
|
||||
/**
|
||||
* @brief Return a list of all unmatched bets for a given account (includes bets on all markets)
|
||||
*/
|
||||
vector<bet_object> get_all_unmatched_bets_for_bettor(account_id_type) const;
|
||||
|
||||
/////////////////////
|
||||
// Markets / feeds //
|
||||
/////////////////////
|
||||
|
|
@ -709,6 +714,7 @@ FC_API(graphene::app::database_api,
|
|||
(list_betting_market_groups)
|
||||
(list_betting_markets)
|
||||
(get_unmatched_bets_for_bettor)
|
||||
(get_all_unmatched_bets_for_bettor)
|
||||
|
||||
// Markets / feeds
|
||||
(get_order_book)
|
||||
|
|
|
|||
|
|
@ -337,116 +337,116 @@ struct compare_bet_by_odds {
|
|||
struct compare_bet_by_bettor_then_odds {
|
||||
bool operator()(const bet_object& lhs, const bet_object& rhs) const
|
||||
{
|
||||
return compare(lhs.betting_market_id, lhs.bettor_id, lhs.back_or_lay, lhs.backer_multiplier, lhs.id,
|
||||
rhs.betting_market_id, rhs.bettor_id, rhs.back_or_lay, rhs.backer_multiplier, rhs.id);
|
||||
return compare(lhs.bettor_id, lhs.betting_market_id, lhs.back_or_lay, lhs.backer_multiplier, lhs.id,
|
||||
rhs.bettor_id, rhs.betting_market_id, rhs.back_or_lay, rhs.backer_multiplier, rhs.id);
|
||||
}
|
||||
|
||||
template<typename T0>
|
||||
bool operator() (const std::tuple<T0>& lhs, const bet_object& rhs) const
|
||||
{
|
||||
return compare(std::get<0>(lhs), rhs.betting_market_id);
|
||||
return compare(std::get<0>(lhs), rhs.bettor_id);
|
||||
}
|
||||
|
||||
template<typename T0>
|
||||
bool operator() (const bet_object& lhs, const std::tuple<T0>& rhs) const
|
||||
{
|
||||
return compare(lhs.betting_market_id, std::get<0>(rhs));
|
||||
return compare(lhs.bettor_id, std::get<0>(rhs));
|
||||
}
|
||||
|
||||
template<typename T0, typename T1>
|
||||
bool operator() (const std::tuple<T0, T1>& lhs, const bet_object& rhs) const
|
||||
{
|
||||
return compare(std::get<0>(lhs), std::get<1>(lhs), rhs.betting_market_id, rhs.bettor_id);
|
||||
return compare(std::get<0>(lhs), std::get<1>(lhs), rhs.bettor_id, rhs.betting_market_id);
|
||||
}
|
||||
|
||||
template<typename T0, typename T1>
|
||||
bool operator() (const bet_object& lhs, const std::tuple<T0, T1>& rhs) const
|
||||
{
|
||||
return compare(lhs.betting_market_id, lhs.bettor_id, std::get<0>(rhs), std::get<1>(rhs));
|
||||
return compare(lhs.bettor_id, lhs.betting_market_id, std::get<0>(rhs), std::get<1>(rhs));
|
||||
}
|
||||
|
||||
template<typename T0, typename T1, typename T2>
|
||||
bool operator() (const std::tuple<T0, T1, T2>& lhs, const bet_object& rhs) const
|
||||
{
|
||||
return compare(std::get<0>(lhs), std::get<1>(lhs), std::get<2>(lhs),
|
||||
rhs.betting_market_id, rhs.bettor_id, rhs.back_or_lay);
|
||||
rhs.bettor_id, rhs.betting_market_id, rhs.back_or_lay);
|
||||
}
|
||||
|
||||
template<typename T0, typename T1, typename T2>
|
||||
bool operator() (const bet_object& lhs, const std::tuple<T0, T1, T2>& rhs) const
|
||||
{
|
||||
return compare(lhs.betting_market_id, lhs.bettor_id, lhs.back_or_lay,
|
||||
return compare(lhs.bettor_id, lhs.betting_market_id, lhs.back_or_lay,
|
||||
std::get<0>(rhs), std::get<1>(rhs), std::get<2>(rhs));
|
||||
}
|
||||
template<typename T0, typename T1, typename T2, typename T3>
|
||||
bool operator() (const std::tuple<T0, T1, T2, T3>& lhs, const bet_object& rhs) const
|
||||
{
|
||||
return compare(std::get<0>(lhs), std::get<1>(lhs), std::get<2>(lhs), std::get<3>(lhs),
|
||||
rhs.betting_market_id, rhs.bettor_id, rhs.back_or_lay, rhs.backer_multiplier);
|
||||
rhs.bettor_id, rhs.betting_market_id, rhs.back_or_lay, rhs.backer_multiplier);
|
||||
}
|
||||
|
||||
template<typename T0, typename T1, typename T2, typename T3>
|
||||
bool operator() (const bet_object& lhs, const std::tuple<T0, T1, T2, T3>& rhs) const
|
||||
{
|
||||
return compare(lhs.betting_market_id, lhs.bettor_id, lhs.back_or_lay, lhs.backer_multiplier, lhs.id,
|
||||
return compare(lhs.bettor_id, lhs.betting_market_id, lhs.back_or_lay, lhs.backer_multiplier, lhs.id,
|
||||
std::get<0>(rhs), std::get<1>(rhs), std::get<2>(rhs), std::get<3>(rhs));
|
||||
}
|
||||
template<typename T0, typename T1, typename T2, typename T3, typename T4>
|
||||
bool operator() (const std::tuple<T0, T1, T2, T3, T4>& lhs, const bet_object& rhs) const
|
||||
{
|
||||
return compare(std::get<0>(lhs), std::get<1>(lhs), std::get<2>(lhs), std::get<3>(lhs), std::get<4>(lhs),
|
||||
rhs.betting_market_id, rhs.bettor_id, rhs.back_or_lay, rhs.backer_multiplier, rhs.id);
|
||||
rhs.bettor_id, rhs.betting_market_id, rhs.back_or_lay, rhs.backer_multiplier, rhs.id);
|
||||
}
|
||||
template<typename T0, typename T1, typename T2, typename T3, typename T4>
|
||||
bool operator() (const bet_object& lhs, const std::tuple<T0, T1, T2, T3, T4>& rhs) const
|
||||
{
|
||||
return compare(lhs.betting_market_id, lhs.bettor_id, lhs.back_or_lay, lhs.backer_multiplier, lhs.id,
|
||||
return compare(lhs.bettor_id, lhs.betting_market_id, lhs.back_or_lay, lhs.backer_multiplier, lhs.id,
|
||||
std::get<0>(rhs), std::get<1>(rhs), std::get<2>(rhs), std::get<3>(rhs), std::get<4>(rhs));
|
||||
}
|
||||
bool compare(const betting_market_id_type& lhs_betting_market_id, const betting_market_id_type& rhs_betting_market_id) const
|
||||
bool compare(const account_id_type& lhs_bettor_id, const account_id_type& rhs_bettor_id) const
|
||||
{
|
||||
return lhs_betting_market_id < rhs_betting_market_id;
|
||||
}
|
||||
bool compare(const betting_market_id_type& lhs_betting_market_id, const account_id_type& lhs_bettor_id,
|
||||
const betting_market_id_type& rhs_betting_market_id, const account_id_type& rhs_bettor_id) const
|
||||
{
|
||||
if (lhs_betting_market_id < rhs_betting_market_id)
|
||||
return true;
|
||||
if (lhs_betting_market_id > rhs_betting_market_id)
|
||||
return false;
|
||||
return lhs_bettor_id < rhs_bettor_id;
|
||||
}
|
||||
|
||||
bool compare(const betting_market_id_type& lhs_betting_market_id, const account_id_type& lhs_bettor_id,
|
||||
bet_type lhs_bet_type,
|
||||
const betting_market_id_type& rhs_betting_market_id, const account_id_type& rhs_bettor_id,
|
||||
bet_type rhs_bet_type) const
|
||||
bool compare(const account_id_type& lhs_bettor_id, const betting_market_id_type& lhs_betting_market_id,
|
||||
const account_id_type& rhs_bettor_id, const betting_market_id_type& rhs_betting_market_id) const
|
||||
{
|
||||
if (lhs_betting_market_id < rhs_betting_market_id)
|
||||
return true;
|
||||
if (lhs_betting_market_id > rhs_betting_market_id)
|
||||
return false;
|
||||
if (lhs_bettor_id < rhs_bettor_id)
|
||||
return true;
|
||||
if (lhs_bettor_id > rhs_bettor_id)
|
||||
return false;
|
||||
return lhs_betting_market_id < rhs_betting_market_id;
|
||||
}
|
||||
|
||||
bool compare(const account_id_type& lhs_bettor_id, const betting_market_id_type& lhs_betting_market_id,
|
||||
bet_type lhs_bet_type,
|
||||
const account_id_type& rhs_bettor_id, const betting_market_id_type& rhs_betting_market_id,
|
||||
bet_type rhs_bet_type) const
|
||||
{
|
||||
if (lhs_bettor_id < rhs_bettor_id)
|
||||
return true;
|
||||
if (lhs_bettor_id > rhs_bettor_id)
|
||||
return false;
|
||||
if (lhs_betting_market_id < rhs_betting_market_id)
|
||||
return true;
|
||||
if (lhs_betting_market_id > rhs_betting_market_id)
|
||||
return false;
|
||||
return lhs_bet_type < rhs_bet_type;
|
||||
}
|
||||
bool compare(const betting_market_id_type& lhs_betting_market_id, const account_id_type& lhs_bettor_id,
|
||||
bool compare(const account_id_type& lhs_bettor_id, const betting_market_id_type& lhs_betting_market_id,
|
||||
bet_type lhs_bet_type,
|
||||
bet_multiplier_type lhs_backer_multiplier,
|
||||
const betting_market_id_type& rhs_betting_market_id, const account_id_type& rhs_bettor_id,
|
||||
const account_id_type& rhs_bettor_id, const betting_market_id_type& rhs_betting_market_id,
|
||||
bet_type rhs_bet_type,
|
||||
bet_multiplier_type rhs_backer_multiplier) const
|
||||
{
|
||||
if (lhs_betting_market_id < rhs_betting_market_id)
|
||||
return true;
|
||||
if (lhs_betting_market_id > rhs_betting_market_id)
|
||||
return false;
|
||||
if (lhs_bettor_id < rhs_bettor_id)
|
||||
return true;
|
||||
if (lhs_bettor_id > rhs_bettor_id)
|
||||
return false;
|
||||
if (lhs_betting_market_id < rhs_betting_market_id)
|
||||
return true;
|
||||
if (lhs_betting_market_id > rhs_betting_market_id)
|
||||
return false;
|
||||
if (lhs_bet_type < rhs_bet_type)
|
||||
return true;
|
||||
if (lhs_bet_type > rhs_bet_type)
|
||||
|
|
@ -456,21 +456,21 @@ struct compare_bet_by_bettor_then_odds {
|
|||
else
|
||||
return lhs_backer_multiplier > rhs_backer_multiplier;
|
||||
}
|
||||
bool compare(const betting_market_id_type& lhs_betting_market_id, const account_id_type& lhs_bettor_id,
|
||||
bool compare(const account_id_type& lhs_bettor_id, const betting_market_id_type& lhs_betting_market_id,
|
||||
bet_type lhs_bet_type,
|
||||
bet_multiplier_type lhs_backer_multiplier, const bet_id_type& lhs_bet_id,
|
||||
const betting_market_id_type& rhs_betting_market_id, const account_id_type& rhs_bettor_id,
|
||||
const account_id_type& rhs_bettor_id, const betting_market_id_type& rhs_betting_market_id,
|
||||
bet_type rhs_bet_type,
|
||||
bet_multiplier_type rhs_backer_multiplier, const bet_id_type& rhs_bet_id) const
|
||||
{
|
||||
if (lhs_betting_market_id < rhs_betting_market_id)
|
||||
return true;
|
||||
if (lhs_betting_market_id > rhs_betting_market_id)
|
||||
return false;
|
||||
if (lhs_bettor_id < rhs_bettor_id)
|
||||
return true;
|
||||
if (lhs_bettor_id > rhs_bettor_id)
|
||||
return false;
|
||||
if (lhs_betting_market_id < rhs_betting_market_id)
|
||||
return true;
|
||||
if (lhs_betting_market_id > rhs_betting_market_id)
|
||||
return false;
|
||||
if (lhs_bet_type < rhs_bet_type)
|
||||
return true;
|
||||
if (lhs_bet_type > rhs_bet_type)
|
||||
|
|
|
|||
Loading…
Reference in a new issue