EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MarketDB Class Reference

#include "MarketDB.h"

Inheritance diagram for MarketDB:
Collaboration diagram for MarketDB:

Public Member Functions

PyRepGetMarketGroups ()
 
PyRepGetOrders (uint32 regionID, uint16 typeID)
 
PyRepGetOrderRow (uint32 orderID)
 
PyRepGetRegionBest (uint32 regionID)
 
PyRepGetSystemAsks (uint32 solarSystemID)
 
PyRepGetStationAsks (uint32 stationID)
 
PyRepGetOrdersForOwner (uint32 ownerID)
 
PyRepGetTransactions (uint32 ownerID, Market::TxData &data)
 
bool DeleteOrder (uint32 orderID)
 
bool GetOrderInfo (uint32 orderID, Market::OrderInfo &oInfo)
 
bool AlterOrderPrice (uint32 orderID, double new_price)
 
bool RecordTransaction (Market::TxData &data)
 
bool AlterOrderQuantity (uint32 orderID, uint32 new_qty)
 
uint32 FindBuyOrder (Call_PlaceCharOrder &call)
 
uint32 FindSellOrder (Call_PlaceCharOrder &call)
 
uint32 StoreOrder (Market::SaveData &data)
 
- Public Member Functions inherited from ServiceDB
uint32 GetStationOwner (uint32 stationID)
 

Static Public Member Functions

static void GetShipIDs (std::map< uint16, Inv::TypeData > &data)
 
static void GetMineralPrices (std::map< uint16, Market::matlData > &data)
 
static void GetMaterialPrices (std::map< uint16, Market::matlData > &data)
 
static void GetManufacturedItems (std::map< uint16, Inv::TypeData > &data)
 
static void UpdateInvPrice (std::map< uint16, Inv::TypeData > &data)
 
static void UpdateMktPrice (std::map< uint16, Market::matlData > &data)
 
static void GetCruPriceAvg (std::map< uint16, Inv::TypeData > &data)
 
static int64 GetUpdateTime ()
 
static void SetUpdateTime (int64 setTime)
 
static void UpdateHistory ()
 
- Static Public Member Functions inherited from ServiceDB
static bool GetAccountInformation (CryptoChallengePacket &ccp, AccountData &aData, std::string &failMsg)
 
static bool UpdateAccountHash (const char *username, std::string &hash)
 
static bool IncrementLoginCount (uint32 accountID)
 
static void UpdatePassword (uint32 accountID, const char *pass)
 
static void SaveKillOrLoss (CharKillData &data)
 
static bool GetConstant (const char *name, uint32 &into)
 
static void SetServerOnlineStatus (bool online=false)
 
static void SetCharacterOnlineStatus (uint32 char_id, bool online=false)
 
static void SetAccountOnlineStatus (uint32 accountID, bool online=false)
 
static void SetAccountBanStatus (uint32 accountID, bool banned=false)
 
static void SaveServerStats (double threads, float rss, float vm, float user, float kernel, uint32 items, uint32 bubbles)
 
static uint32 SetClientSeed ()
 
static PyRepLookupChars (const char *match, bool exact=false)
 
static PyRepLookupOwners (const char *match, bool exact=false)
 
static PyRepLookupCorporations (const std::string &)
 
static PyRepLookupFactions (const std::string &)
 
static PyRepLookupCorporationTickers (const std::string &)
 
static PyRepLookupStations (const std::string &)
 
static PyRepLookupKnownLocationsByGroup (const std::string &, uint32)
 
static PyRepPrimeOwners (std::vector< int32 > &itemIDs)
 
static bool ValidateAccountName (CryptoChallengePacket &ccp, std::string &failMsg)
 
static void GetCorpHangarNames (uint32 corpID, std::map< uint8, std::string > &hangarNames)
 

Additional Inherited Members

- Protected Member Functions inherited from ServiceDB
void ProcessStringChange (const char *key, const std::string &oldValue, std::string newValue, PyDict *notif, std::vector< std::string > &dbQ)
 
void ProcessRealChange (const char *key, double oldValue, double newValue, PyDict *notif, std::vector< std::string > &dbQ)
 
void ProcessIntChange (const char *key, uint32 oldValue, uint32 newValue, PyDict *notif, std::vector< std::string > &dbQ)
 
void ProcessLongChange (const char *key, int64 oldValue, int64 newValue, PyDict *notif, std::vector< std::string > &dbQ)
 
- Static Protected Member Functions inherited from ServiceDB
static uint32 CreateNewAccount (const char *login, const char *pass, const char *passHash, int64 role)
 

Detailed Description

Definition at line 38 of file MarketDB.h.

Member Function Documentation

bool MarketDB::AlterOrderPrice ( uint32  orderID,
double  new_price 
)

Definition at line 307 of file MarketDB.cpp.

References _log, DBerror::c_str(), and sDatabase.

307  {
308  DBerror err;
309  if (!sDatabase.RunQuery(err, "UPDATE mktOrders SET price = %.2f WHERE orderID = %u", new_price, orderID)) {
310  _log(MARKET__DB_ERROR, "Error in query: %s.", err.c_str());
311  return false;
312  }
313  return true;
314 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
Definition: dbcore.h:39

Here is the call graph for this function:

bool MarketDB::AlterOrderQuantity ( uint32  orderID,
uint32  new_qty 
)

Definition at line 298 of file MarketDB.cpp.

References _log, DBerror::c_str(), and sDatabase.

Referenced by MarketMgr::ExecuteBuyOrder(), and MarketMgr::ExecuteSellOrder().

298  {
299  DBerror err;
300  if (!sDatabase.RunQuery(err, "UPDATE mktOrders SET volRemaining = %u WHERE orderID = %u", new_qty, orderID)) {
301  _log(MARKET__DB_ERROR, "Error in query: %s.", err.c_str());
302  return false;
303  }
304  return true;
305 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
Definition: dbcore.h:39

Here is the call graph for this function:

Here is the caller graph for this function:

bool MarketDB::DeleteOrder ( uint32  orderID)

Definition at line 316 of file MarketDB.cpp.

References _log, DBerror::c_str(), and sDatabase.

Referenced by MarketMgr::ExecuteBuyOrder(), and MarketMgr::ExecuteSellOrder().

316  {
317  DBerror err;
318  if (!sDatabase.RunQuery(err, "DELETE FROM mktOrders WHERE orderID = %u", orderID)) {
319  _log(MARKET__DB_ERROR, "Error in query: %s.", err.c_str());
320  return false;
321  }
322  return true;
323 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
Definition: dbcore.h:39

Here is the call graph for this function:

Here is the caller graph for this function:

uint32 MarketDB::FindBuyOrder ( Call_PlaceCharOrder &  call)

Definition at line 196 of file MarketDB.cpp.

References DBerror::c_str(), codelog, DBQueryResult::error, DBQueryResult::GetRow(), DBResultRow::GetUInt(), and sDatabase.

196  {
197  DBQueryResult res;
198  if (!sDatabase.RunQuery(res,
199  "SELECT orderID"
200  " FROM mktOrders"
201  " WHERE bid=1"
202  " AND typeID=%u"
203  " AND stationID=%u"
204  " AND volRemaining >= %u"
205  " AND price > %.2f"
206  " ORDER BY price DESC"
207  " LIMIT 1;",
208  call.typeID,
209  call.stationID,
210  call.quantity,
211  call.price - 0.1/*, sConfig.market.FindBuyOrder*/))
212  {
213  codelog(MARKET__DB_ERROR, "Error in query: %s", res.error.c_str());
214  return 0;
215  }
216 
217  DBResultRow row;
218  if (res.GetRow(row))
219  return row.GetUInt(0);
220 
221  return 0; //no order found.
222 }
#define sDatabase
Definition: dbcore.h:199
uint32 GetUInt(uint32 index) const
Definition: dbcore.cpp:658
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

uint32 MarketDB::FindSellOrder ( Call_PlaceCharOrder &  call)

Definition at line 224 of file MarketDB.cpp.

References DBerror::c_str(), codelog, DBQueryResult::error, DBQueryResult::GetRow(), DBResultRow::GetUInt(), and sDatabase.

225 {
226  DBQueryResult res;
227  if (!sDatabase.RunQuery(res,
228  "SELECT orderID"
229  " FROM mktOrders"
230  " WHERE bid=0"
231  " AND typeID=%u"
232  " AND stationID=%u"
233  " AND volRemaining >= %u"
234  " AND price < %.2f"
235  " ORDER BY price ASC"
236  " LIMIT 1;",
237  call.typeID,
238  call.stationID,
239  call.quantity,
240  call.price + 0.1/*, sConfig.market.FindSellOrder*/))
241  {
242  codelog(MARKET__DB_ERROR, "Error in query: %s", res.error.c_str());
243  return 0;
244  }
245 
246  DBResultRow row;
247  if (res.GetRow(row))
248  return row.GetUInt(0);
249 
250  return 0;
251 }
#define sDatabase
Definition: dbcore.h:199
uint32 GetUInt(uint32 index) const
Definition: dbcore.cpp:658
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

void MarketDB::GetCruPriceAvg ( std::map< uint16, Inv::TypeData > &  data)
static

Definition at line 590 of file MarketDB.cpp.

References DBResultRow::GetFloat(), DBQueryResult::GetRow(), DBResultRow::IsNull(), and sDatabase.

Referenced by MarketMgr::GetCruPrices(), and MarketMgr::SetBasePrice().

591 {
592  DBQueryResult res;
593  DBResultRow row;
594  std::map< uint16, Inv::TypeData>::iterator itr;
595  for (itr = data.begin(); itr != data.end(); ++itr) {
596  sDatabase.RunQuery(res, "SELECT AVG(avgPrice) FROM CruciblePriceHistory WHERE typeID = %u", itr->first);
597  if (res.GetRow(row))
598  itr->second.basePrice = (row.IsNull(0) ? 0 : row.GetFloat(0));
599  }
600 }
#define sDatabase
Definition: dbcore.h:199
float GetFloat(uint32 index) const
Definition: dbcore.cpp:682
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
bool IsNull(uint32 index) const
Definition: dbcore.h:102

Here is the call graph for this function:

Here is the caller graph for this function:

void MarketDB::GetManufacturedItems ( std::map< uint16, Inv::TypeData > &  data)
static

Definition at line 519 of file MarketDB.cpp.

References DBerror::c_str(), codelog, DBQueryResult::error, DBResultRow::GetInt(), DBQueryResult::GetRow(), and sDatabase.

Referenced by MarketMgr::SetBasePrice().

520 {
521  DBQueryResult res;
522  DBResultRow row;
523  //6602 items in this query
524  if (!sDatabase.RunQuery(res, "SELECT DISTINCT typeID FROM invTypeMaterials"))
525  codelog(DATABASE__ERROR, "Error in GetRAMMaterials query: %s", res.error.c_str());
526 
527  while (res.GetRow(row))
528  data[row.GetInt(0)] = Inv::TypeData();
529 }
#define sDatabase
Definition: dbcore.h:199
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

Here is the caller graph for this function:

PyRep * MarketDB::GetMarketGroups ( )

Definition at line 401 of file MarketDB.cpp.

References _log, DBerror::c_str(), codelog, DBRowDescriptor::ColumnCount(), DBQueryResult::error, DBResultRow::GetBool(), DBQueryResult::GetRow(), DBResultRow::GetText(), DBResultRow::GetUInt(), is_log_enabled, DBResultRow::IsNull(), CRowSet::NewRow(), PyStatic, sDatabase, PyPackedRow::SetField(), and PyDict::SetItemString().

Referenced by MarketMgr::Populate().

401  {
402 
403  DBQueryResult res;
404  if (!sDatabase.RunQuery(res, "SELECT parentGroupID, marketGroupID, marketGroupName,"
405  " description, graphicID, hasTypes, iconID, dataID, marketGroupNameID, descriptionID"
406  " FROM invMarketGroups")) {
407  codelog(MARKET__DB_ERROR, "Error in query: %s", res.error.c_str());
408  return nullptr;
409  }
410 
411  DBRowDescriptor *header = new DBRowDescriptor(res);
412 
413  _log(MARKET__DB_TRACE, "GetMarketGroups header has %u columns.", header->ColumnCount());
414 
415  CFilterRowSet *filterRowset = new CFilterRowSet(&header);
416  PyDict *keywords = filterRowset->GetKeywords();
417  keywords->SetItemString("allowDuplicateCompoundKeys", PyStatic.NewFalse());
418  keywords->SetItemString("indexName", PyStatic.NewNone());
419  keywords->SetItemString("columnName", new PyString("parentGroupID"));
420 
421  DBResultRow row;
422  std::map< int, PyRep* > tt;
423  while( res.GetRow(row) ) {
424  int parentGroupID(row.IsNull(0) ? -1 : row.GetUInt(0));
425  PyRep* pid(nullptr);
426  CRowSet*rowset(nullptr);
427  if (tt.count(parentGroupID)) {
428  pid = tt[parentGroupID];
429  rowset = filterRowset->GetRowset(pid);
430  } else {
431  pid = parentGroupID != -1 ? (PyRep*)new PyInt(parentGroupID) : PyStatic.NewNone();
432  tt[parentGroupID] = pid;
433  rowset = filterRowset->NewRowset(pid);
434  }
435 
436  PyPackedRow* pyrow = rowset->NewRow();
437  pyrow->SetField((uint32)0, pid); //parentGroupID
438  pyrow->SetField(1, new PyInt(row.GetUInt(1))); //marketGroupID
439  pyrow->SetField(2, new PyString(row.GetText(2))); //marketGroupName
440  pyrow->SetField(3, new PyString(row.GetText(3))); //description
441  pyrow->SetField(4, row.IsNull(4) ? PyStatic.NewNone() : new PyInt(row.GetUInt(4))); //graphicID
442  pyrow->SetField(5, new PyBool(row.GetBool(5))); //hasTypes
443  pyrow->SetField(6, row.IsNull(6) ? PyStatic.NewNone() : new PyInt(row.GetUInt(6))); // iconID
444  pyrow->SetField(7, new PyInt(row.GetUInt(7))); //dataID
445  pyrow->SetField(8, new PyInt(row.GetUInt(8))); //marketGroupNameID
446  pyrow->SetField(9, new PyInt(row.GetUInt(9))); //descriptionID
447  }
448 
449  _log(MARKET__DB_TRACE, "GetMarketGroups returned %u keys.", filterRowset->GetKeyCount());
450  if (is_log_enabled(MARKET__DB_TRACE))
451  filterRowset->Dump(MARKET__DB_TRACE, " ");
452 
453  return filterRowset;
454 }
Base Python wire object.
Definition: PyRep.h:66
#define sDatabase
Definition: dbcore.h:199
const char * GetText(uint32 index) const
Definition: dbcore.h:104
#define _log(type, fmt,...)
Definition: logsys.h:124
Python string.
Definition: PyRep.h:430
Python object "dbutil.CFilterRowset".
Definition: PyDatabase.h:216
Python's dictionary.
Definition: PyRep.h:719
uint32 GetUInt(uint32 index) const
Definition: dbcore.cpp:658
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
bool GetBool(uint32 index) const
Definition: dbcore.cpp:647
Python boolean.
Definition: PyRep.h:323
#define is_log_enabled(type)
Definition: logsys.h:78
const char * c_str() const
Definition: dbcore.h:48
Python object "blue.DBRowDescriptor".
Definition: PyDatabase.h:41
uint32 ColumnCount() const
Definition: PyDatabase.cpp:60
#define codelog(type, fmt,...)
Definition: logsys.h:128
Python object "dbutil.CRowset".
Definition: PyDatabase.h:124
Python integer.
Definition: PyRep.h:231
#define PyStatic
Definition: PyRep.h:1209
bool IsNull(uint32 index) const
Definition: dbcore.h:102
unsigned __int32 uint32
Definition: eve-compat.h:50
DBerror error
Definition: dbcore.h:69
bool SetField(uint32 index, PyRep *value)
Definition: PyRep.cpp:1031
Packed row.
Definition: PyRep.h:961
void SetItemString(const char *key, PyRep *value)
SetItemString adds or sets a database entry.
Definition: PyRep.h:812

Here is the call graph for this function:

Here is the caller graph for this function:

void MarketDB::GetMaterialPrices ( std::map< uint16, Market::matlData > &  data)
static

Definition at line 531 of file MarketDB.cpp.

References DBResultRow::GetFloat(), DBQueryResult::GetRow(), and sDatabase.

Referenced by MarketMgr::SetBasePrice().

532 {
533  DBQueryResult res;
534  DBResultRow row;
535  std::map< uint16, Market::matlData >::iterator itr;
536  for (itr = data.begin(); itr != data.end(); ++itr) {
537  sDatabase.RunQuery(res, "SELECT basePrice FROM invTypes WHERE typeID = %u", itr->first);
538  if (res.GetRow(row))
539  itr->second.price = (row.GetFloat(0) * 1.05);
540  }
541 }
#define sDatabase
Definition: dbcore.h:199
float GetFloat(uint32 index) const
Definition: dbcore.cpp:682
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552

Here is the call graph for this function:

Here is the caller graph for this function:

void MarketDB::GetMineralPrices ( std::map< uint16, Market::matlData > &  data)
static

Definition at line 543 of file MarketDB.cpp.

References DBResultRow::GetFloat(), DBQueryResult::GetRow(), and sDatabase.

Referenced by MarketMgr::SetBasePrice().

544 {
545  DBQueryResult res;
546  DBResultRow row;
547  std::map< uint16, Market::matlData >::iterator itr;
548  for (itr = data.begin(); itr != data.end(); ++itr) {
549  sDatabase.RunQuery(res, "SELECT basePrice FROM invTypes WHERE typeID = %u", itr->first);
550  if (res.GetRow(row))
551  itr->second.price = (row.GetFloat(0) * 1.15);
552  }
553 
554  /* mineral prices in first column from rens 31/5/2010 @ 17:30 logged by me from IGB
555  * second price column is from Grismar 16/2/07
556  * third price column is from ccp market dump, filtered and averaged for Crucible era from all regions
557  * typeID Name 2010 2007 2012
558  * 34 Tritanium 2.70 2.37 2.72315
559  * 35 Pyerite 5.80 4.00 4.90957
560  * 36 Mexallon 26.90 21.93 29.7163
561  * 37 Isogen 49.16 64.06 59.1943
562  * 38 Nocxium 99.02 93.76 94.227
563  * 39 Zydrine 1315.03 2347.36 1290.39
564  * 40 Megacyte 2650.00 3989.06 2707.67
565  * 11399 Morphite 5407.68 14291.00 4943.2
566  *
567  */
568 }
#define sDatabase
Definition: dbcore.h:199
float GetFloat(uint32 index) const
Definition: dbcore.cpp:682
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552

Here is the call graph for this function:

Here is the caller graph for this function:

bool MarketDB::GetOrderInfo ( uint32  orderID,
Market::OrderInfo oInfo 
)

Definition at line 253 of file MarketDB.cpp.

References _log, Market::OrderInfo::accountKey, DBerror::c_str(), DBQueryResult::error, DBResultRow::GetBool(), DBResultRow::GetFloat(), DBQueryResult::GetRow(), DBResultRow::GetUInt(), Market::OrderInfo::isBuy, Market::OrderInfo::isCorp, Market::OrderInfo::memberID, Market::OrderInfo::ownerID, Market::OrderInfo::price, Market::OrderInfo::quantity, Market::OrderInfo::regionID, sDatabase, Market::OrderInfo::stationID, and Market::OrderInfo::typeID.

Referenced by MarketMgr::ExecuteBuyOrder(), and MarketMgr::ExecuteSellOrder().

253  {
254  //orderID, typeID, ownerID, regionID, stationID, orderRange, bid, price, escrow,
255  // minVolume, volEntered, volRemaining, issued, contraband, duration, jumps, isCorp, accountKey, memberID
256  DBQueryResult res;
257  if (!sDatabase.RunQuery(res,
258  "SELECT"
259  " volRemaining,"
260  " price,"
261  " typeID,"
262  " stationID,"
263  " regionID,"
264  " ownerID,"
265  " bid,"
266  " isCorp,"
267  " memberID,"
268  " accountKey"
269  " FROM mktOrders"
270  " WHERE orderID=%u",
271  orderID))
272  {
273  _log(MARKET__DB_ERROR, "Error in query: %s.", res.error.c_str());
274  return false;
275  }
276 
277  DBResultRow row;
278  if (!res.GetRow(row)) {
279  _log(MARKET__WARNING, "Order %u not found.", orderID);
280  return false;
281  }
282 
283  oInfo.quantity = row.GetUInt(0);
284  oInfo.price = row.GetFloat(1);
285  oInfo.typeID = row.GetUInt(2);
286  oInfo.stationID = row.GetUInt(3);
287  oInfo.regionID = row.GetUInt(4);
288  oInfo.ownerID = row.GetUInt(5);
289  oInfo.isBuy = row.GetBool(6);
290  oInfo.isCorp = row.GetBool(7);
291  oInfo.memberID = row.GetUInt(8);
292  oInfo.accountKey = row.GetUInt(9);
293 
294  return true;
295 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
float GetFloat(uint32 index) const
Definition: dbcore.cpp:682
uint32 GetUInt(uint32 index) const
Definition: dbcore.cpp:658
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
bool GetBool(uint32 index) const
Definition: dbcore.cpp:647
const char * c_str() const
Definition: dbcore.h:48
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

Here is the caller graph for this function:

PyRep * MarketDB::GetOrderRow ( uint32  orderID)

Definition at line 172 of file MarketDB.cpp.

References DBerror::c_str(), codelog, DBRowToPackedRow(), DBQueryResult::error, DBQueryResult::GetRow(), and sDatabase.

Referenced by MarketMgr::ExecuteBuyOrder(), MarketMgr::ExecuteSellOrder(), and MarketMgr::SendOnOwnOrderChanged().

172  {
173  DBQueryResult res;
174  if (!sDatabase.RunQuery(res,
175  "SELECT"
176  " price, volRemaining, typeID, orderRange AS `range`, orderID,"
177  " volEntered, minVolume, bid, issued as issueDate, duration,"
178  " stationID, regionID, solarSystemID, jumps"
179  " FROM mktOrders"
180  " WHERE orderID=%u", orderID))
181  {
182  codelog(MARKET__DB_ERROR, "Error in query: %s", res.error.c_str());
183  return nullptr;
184  }
185 
186  DBResultRow row;
187  if (!res.GetRow(row)) {
188  codelog(MARKET__ERROR, "Order %u not found.", orderID);
189  return nullptr;
190  }
191 
192  return DBRowToPackedRow(row);
193 }
#define sDatabase
Definition: dbcore.h:199
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
DBerror error
Definition: dbcore.h:69
PyPackedRow * DBRowToPackedRow(DBResultRow &row)
Definition: EVEDBUtils.cpp:453

Here is the call graph for this function:

Here is the caller graph for this function:

PyRep * MarketDB::GetOrders ( uint32  regionID,
uint16  typeID 
)

Definition at line 109 of file MarketDB.cpp.

References _log, Market::Type::Buy, DBerror::c_str(), codelog, DBResultToCRowset(), PyRep::Dump(), DBQueryResult::error, DBQueryResult::GetRowCount(), is_log_enabled, PyDecRef, sDatabase, Market::Type::Sell, and PyTuple::SetItem().

110 {
111  // returns a tuple (sell, buy) of PyObjectEx with data in PyPackedRows
112 
113  PyTuple* tup = new PyTuple(2);
114  DBQueryResult res;
115  //query sell orders
116  if (!sDatabase.RunQuery(res,
117  "SELECT"
118  " price, volRemaining, typeID, orderRange AS `range`, orderID,"
119  " volEntered, minVolume, bid, issued as issueDate, duration,"
120  " stationID, regionID, solarSystemID, jumps"
121  " FROM mktOrders "
122  " WHERE regionID=%u AND typeID=%u AND bid=%u", regionID, typeID, Market::Type::Sell))
123  {
124  codelog( MARKET__DB_ERROR, "Error in query: %s", res.error.c_str() );
125  return nullptr;
126  }
127  _log(MARKET__DB_TRACE, "GetOrders() - Fetched %u sell orders for type %u", res.GetRowCount(), typeID);
128  tup->SetItem(0, DBResultToCRowset( res ) );
129 
130  //query buy orders
131  if (!sDatabase.RunQuery(res,
132  "SELECT"
133  " price, volRemaining, typeID, orderRange AS `range`, orderID,"
134  " volEntered, minVolume, bid, issued as issueDate, duration,"
135  " stationID, regionID, solarSystemID, jumps"
136  " FROM mktOrders "
137  " WHERE regionID=%u AND typeID=%u AND bid=%u", regionID, typeID, Market::Type::Buy))
138  {
139  codelog( MARKET__DB_ERROR, "Error in query: %s", res.error.c_str() );
140  PyDecRef( tup );
141  return nullptr;
142  }
143  _log(MARKET__DB_TRACE, "GetOrders() - Fetched %u buy orders for type %u", res.GetRowCount(), typeID);
144  tup->SetItem(1, DBResultToCRowset( res ) );
145 
146  if (is_log_enabled(MARKET__DUMP))
147  tup->Dump(MARKET__DUMP, " ");
148  return tup;
149 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
PyObjectEx * DBResultToCRowset(DBQueryResult &result)
Definition: EVEDBUtils.cpp:402
Python tuple.
Definition: PyRep.h:567
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
Definition: PyRep.cpp:84
#define is_log_enabled(type)
Definition: logsys.h:78
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
void SetItem(size_t index, PyRep *object)
Stores Python object.
Definition: PyRep.h:610
#define PyDecRef(op)
Definition: PyRep.h:57
DBerror error
Definition: dbcore.h:69
size_t GetRowCount()
Definition: dbcore.h:72

Here is the call graph for this function:

PyRep * MarketDB::GetOrdersForOwner ( uint32  ownerID)

Definition at line 151 of file MarketDB.cpp.

References _log, DBerror::c_str(), codelog, DBResultToRowset(), DBQueryResult::error, DBQueryResult::GetRowCount(), and sDatabase.

152 {
153  DBQueryResult res;
154  if (!sDatabase.RunQuery(res,
155  "SELECT"
156  " orderID, typeID, ownerID AS charID, regionID, stationID,"
157  " orderRange AS `range`, bid, price, volEntered, volRemaining,"
158  " issued as issueDate, minVolume, contraband,"
159  " duration, isCorp, solarSystemID, escrow"
160  " FROM mktOrders"
161  " WHERE ownerID=%u", ownerID))
162  {
163  codelog(MARKET__DB_ERROR, "Error in query: %s", res.error.c_str());
164  return nullptr;
165  }
166 
167  _log(MARKET__DB_TRACE, "GetOrdersForOwner() - Fetched %u buy orders for %u", res.GetRowCount(), ownerID);
168 
169  return DBResultToRowset(res);
170 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
PyObject * DBResultToRowset(DBQueryResult &result)
Definition: EVEDBUtils.cpp:81
DBerror error
Definition: dbcore.h:69
size_t GetRowCount()
Definition: dbcore.h:72

Here is the call graph for this function:

PyRep * MarketDB::GetRegionBest ( uint32  regionID)

Definition at line 87 of file MarketDB.cpp.

References DBerror::c_str(), codelog, DBResultToIndexRowset(), DBQueryResult::error, sDatabase, and Market::Type::Sell.

87  {
88  DBQueryResult res;
89  if (!sDatabase.RunQuery(res,
90  "SELECT"
91  " typeID, MIN(price) AS price, volRemaining, stationID "
92  " FROM mktOrders "
93  " WHERE regionID=%u AND bid=%u"
94  " GROUP BY typeID",
95  //" LIMIT %u",sConfig.market.RegionOrderLimit
96  regionID, Market::Type::Sell))
97  {
98  codelog(MARKET__DB_ERROR, "Error in query: %s", res.error.c_str());
99  return nullptr;
100  }
101 
102  //NOTE: this SHOULD return a crazy dbutil.RowDict object which is
103  //made up of packed blue.DBRow objects, but we do not understand
104  //the marshalling of those well enough right now, and this object
105  //provides the same interface. It is significantly bigger on the wire though.
106  return DBResultToIndexRowset(res, "typeID");
107 }
#define sDatabase
Definition: dbcore.h:199
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
PyObject * DBResultToIndexRowset(DBQueryResult &result, const char *key)
Definition: EVEDBUtils.cpp:144
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

void MarketDB::GetShipIDs ( std::map< uint16, Inv::TypeData > &  data)
static

Definition at line 500 of file MarketDB.cpp.

References DBResultRow::GetInt(), DBQueryResult::GetRow(), sDatabase, and EVEDB::invCategories::Ship.

501 {
502  DBQueryResult res;
503  DBResultRow row;
504  // 178 ships using this query
505  sDatabase.RunQuery(res,
506  "SELECT t.typeID "
507  " FROM invTypes AS t "
508  " LEFT JOIN invGroups AS g USING (groupID)"
509  " WHERE g.categoryID = %u",
510  //" AND g.useBasePrice = 1"
511  //" AND t.published = 1",
513 
514  //sDatabase.RunQuery(res, "SELECT typeID FROM invTypes WHERE groupID = %u AND published = 1", EVEDB::invGroups::Frigate);
515  while (res.GetRow(row))
516  data[row.GetInt(0)] = Inv::TypeData();
517 }
#define sDatabase
Definition: dbcore.h:199
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552

Here is the call graph for this function:

PyRep * MarketDB::GetStationAsks ( uint32  stationID)

Definition at line 43 of file MarketDB.cpp.

References DBerror::c_str(), codelog, DBResultToIndexRowset(), DBQueryResult::error, and sDatabase.

43  {
44  DBQueryResult res;
45  if (!sDatabase.RunQuery(res,
46  "SELECT"
47  " typeID, MIN(price) AS price, volRemaining, stationID "
48  " FROM mktOrders "
49  " WHERE stationID=%u"
50  " GROUP BY typeID",
51  //" LIMIT %u", sConfig.market.StationOrderLimit
52  stationID))
53  {
54  codelog(MARKET__DB_ERROR, "Error in query: %s", res.error.c_str());
55  return nullptr;
56  }
57 
58  //NOTE: this SHOULD return a crazy dbutil.RowDict object which is
59  //made up of packed blue.DBRow objects, but we do not understand
60  //the marshalling of those well enough right now, and this object
61  //provides the same interface. It is significantly bigger on the wire though.
62  return DBResultToIndexRowset(res, "typeID");
63 }
#define sDatabase
Definition: dbcore.h:199
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
PyObject * DBResultToIndexRowset(DBQueryResult &result, const char *key)
Definition: EVEDBUtils.cpp:144
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

PyRep * MarketDB::GetSystemAsks ( uint32  solarSystemID)

Definition at line 65 of file MarketDB.cpp.

References DBerror::c_str(), codelog, DBResultToIndexRowset(), DBQueryResult::error, and sDatabase.

65  {
66  DBQueryResult res;
67  if (!sDatabase.RunQuery(res,
68  "SELECT"
69  " typeID, MIN(price) AS price, volRemaining, stationID "
70  " FROM mktOrders "
71  " WHERE solarSystemID=%u"
72  " GROUP BY typeID",
73  //" LIMIT %u",sConfig.market.SystemOrderLimit
74  solarSystemID))
75  {
76  codelog(MARKET__DB_ERROR, "Error in query: %s", res.error.c_str());
77  return nullptr;
78  }
79 
80  //NOTE: this SHOULD return a crazy dbutil.RowDict object which is
81  //made up of packed blue.DBRow objects, but we do not understand
82  //the marshalling of those well enough right now, and this object
83  //provides the same interface. It is significantly bigger on the wire though.
84  return DBResultToIndexRowset(res, "typeID");
85 }
#define sDatabase
Definition: dbcore.h:199
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
PyObject * DBResultToIndexRowset(DBQueryResult &result, const char *key)
Definition: EVEDBUtils.cpp:144
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

PyRep * MarketDB::GetTransactions ( uint32  ownerID,
Market::TxData data 
)

Definition at line 349 of file MarketDB.cpp.

References Market::TxData::accountKey, DBerror::c_str(), codelog, DBResultToRowset(), DBQueryResult::error, Market::TxData::isBuy, Market::TxData::memberID, Market::TxData::price, Market::TxData::quantity, sDatabase, Market::TxData::time, and Market::TxData::typeID.

349  {
350  //transactionID, transactionDate, typeID, keyID, quantity, price,
351  // transactionType, clientID, regionID, stationID, corpTransaction, characterID
352  std::string typeID = "";
353  if (data.typeID) {
354  typeID = "AND typeID=";
355  typeID += std::to_string(data.typeID);
356  }
357  std::string buy = "";
358  if (data.isBuy > -1) {
359  buy = "AND transactionType=";
360  buy += std::to_string(data.isBuy);
361  }
362  DBQueryResult res;
363  if (!sDatabase.RunQuery(res,
364  "SELECT"
365  " transactionID, transactionDate, typeID, keyID, quantity, price,"
366  " transactionType, clientID, regionID, stationID, corpTransaction, characterID"
367  " FROM mktTransactions "
368  " WHERE clientID=%u %s AND quantity>=%u AND price>=%.2f AND "
369  " transactionDate>=%li %s AND keyID=%u AND characterID=%u",
370  clientID, typeID.c_str(), data.quantity, data.price,
371  data.time, buy.c_str(), data.accountKey, data.memberID))
372  {
373  codelog(MARKET__DB_ERROR, "Error in query: %s", res.error.c_str());
374  return nullptr;
375  }
376 
377  return DBResultToRowset(res);
378 }
#define sDatabase
Definition: dbcore.h:199
uint32 quantity
Definition: EVE_Market.h:81
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
uint16 typeID
Definition: EVE_Market.h:77
PyObject * DBResultToRowset(DBQueryResult &result)
Definition: EVEDBUtils.cpp:81
uint32 accountKey
Definition: EVE_Market.h:82
uint32 memberID
Definition: EVE_Market.h:83
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

int64 MarketDB::GetUpdateTime ( )
static

Definition at line 456 of file MarketDB.cpp.

References DBerror::c_str(), codelog, DBQueryResult::error, DBResultRow::GetInt64(), DBQueryResult::GetRow(), and sDatabase.

Referenced by MarketMgr::Initialize().

457 {
458  DBQueryResult res;
459  if (!sDatabase.RunQuery(res, "SELECT timeStamp FROM mktUpdates WHERE server = 1")) {
460  codelog(MARKET__DB_ERROR, "Error in query: %s", res.error.c_str());
461  return 0;
462  }
463  DBResultRow row;
464  if (res.GetRow(row))
465  return row.GetInt64(0);
466 
467  return 0;
468 }
#define sDatabase
Definition: dbcore.h:199
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
DBerror error
Definition: dbcore.h:69
int64 GetInt64(uint32 index) const
Definition: dbcore.cpp:670

Here is the call graph for this function:

Here is the caller graph for this function:

bool MarketDB::RecordTransaction ( Market::TxData data)

Definition at line 380 of file MarketDB.cpp.

References Market::TxData::accountKey, DBerror::c_str(), Market::TxData::clientID, codelog, GetFileTimeNow(), Market::TxData::isBuy, Market::TxData::isCorp, Market::TxData::memberID, Market::TxData::price, Market::TxData::quantity, Market::TxData::regionID, sDatabase, Market::TxData::stationID, and Market::TxData::typeID.

Referenced by MarketMgr::ExecuteBuyOrder(), and MarketMgr::ExecuteSellOrder().

380  {
381  //transactionID, transactionDate, typeID, keyID, quantity, price,
382  // transactionType, clientID, regionID, stationID, corpTransaction, characterID
383  DBerror err;
384  if (!sDatabase.RunQuery(err,
385  "INSERT INTO"
386  " mktTransactions ("
387  " transactionDate, typeID, keyID, quantity, price,"
388  " transactionType, clientID, regionID, stationID, corpTransaction, characterID"
389  " ) VALUES ("
390  " %f, %u, %u, %u, %f,"
391  " %u, %u, %u, %u, %u, %u)",
392  GetFileTimeNow(), data.typeID, data.accountKey, data.quantity, data.price,
393  data.isBuy > 0?1:0, data.clientID, data.regionID, data.stationID, data.isCorp?1:0, data.memberID))
394  {
395  codelog(MARKET__DB_ERROR, "Error in query: %s", err.c_str());
396  return false;
397  }
398  return true;
399 }
uint32 regionID
Definition: EVE_Market.h:80
#define sDatabase
Definition: dbcore.h:199
uint32 stationID
Definition: EVE_Market.h:79
uint32 quantity
Definition: EVE_Market.h:81
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
uint16 typeID
Definition: EVE_Market.h:77
uint32 accountKey
Definition: EVE_Market.h:82
uint32 memberID
Definition: EVE_Market.h:83
uint32 clientID
Definition: EVE_Market.h:78
double GetFileTimeNow()
Definition: utils_time.cpp:84
Definition: dbcore.h:39

Here is the call graph for this function:

Here is the caller graph for this function:

void MarketDB::SetUpdateTime ( int64  setTime)
static

Definition at line 470 of file MarketDB.cpp.

References sDatabase.

Referenced by MarketMgr::UpdatePriceHistory().

471 {
472  DBerror err;
473  sDatabase.RunQuery(err, "UPDATE mktUpdates SET timeStamp = %li WHERE server = 1", setTime);
474 }
#define sDatabase
Definition: dbcore.h:199
Definition: dbcore.h:39

Here is the caller graph for this function:

uint32 MarketDB::StoreOrder ( Market::SaveData data)

Definition at line 325 of file MarketDB.cpp.

References Market::SaveData::accountKey, Market::SaveData::bid, DBerror::c_str(), codelog, Market::SaveData::contraband, Market::SaveData::duration, Market::SaveData::escrow, Market::SaveData::isCorp, Market::SaveData::issued, Market::SaveData::jumps, Market::SaveData::memberID, Market::SaveData::minVolume, Market::SaveData::orderRange, Market::SaveData::ownerID, Market::SaveData::price, Market::SaveData::regionID, sDatabase, Market::SaveData::solarSystemID, Market::SaveData::stationID, Market::SaveData::typeID, Market::SaveData::volEntered, and Market::SaveData::volRemaining.

325  {
326  DBerror err;
327  uint32 orderID(0);
328  if (!sDatabase.RunQueryLID(err, orderID,
329  "INSERT INTO mktOrders ("
330  " typeID, ownerID, regionID, stationID, solarSystemID, orderRange,"
331  " bid, price, escrow, minVolume, volEntered, volRemaining,"
332  " issued, contraband, duration, jumps, isCorp, accountKey, memberID"
333  " ) VALUES ("
334  " %u, %u, %u, %u, %u, %u,"
335  " %u, %.2f, %.2f, %u, %u, %u,"
336  " %li, %u, %u, %u, %u, %u, %u"
337  " )",
338  data.typeID, data.ownerID, data.regionID, data.stationID, data.solarSystemID, data.orderRange,
339  data.bid?1:0, data.price, data.escrow, data.minVolume, data.volEntered, data.volRemaining,
340  data.issued, data.contraband?1:0, data.duration, data.jumps, data.isCorp?1:0, data.accountKey, data.memberID))
341  {
342  codelog(MARKET__DB_ERROR, "Error in query: %s", err.c_str());
343  return 0;
344  }
345 
346  return orderID;
347 }
#define sDatabase
Definition: dbcore.h:199
uint32 solarSystemID
Definition: EVE_Market.h:106
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
unsigned __int32 uint32
Definition: eve-compat.h:50
uint32 volRemaining
Definition: EVE_Market.h:109
Definition: dbcore.h:39

Here is the call graph for this function:

void MarketDB::UpdateHistory ( )
static
Todo:
this needs work for better logic. may need to pull data from transactions

Definition at line 477 of file MarketDB.cpp.

References sDatabase.

478 {
479  // 'date' needs to be an actual column to pull data from....
480  DBerror err;
481  sDatabase.RunQuery(err,
482  "INSERT INTO"
483  " mktHistory"
484  " (regionID, typeID, historyDate, lowPrice, highPrice, avgPrice, volume, orders)"
485  " SELECT"
486  " regionID,"
487  " typeID,"
488  " ((UNIX_TIMESTAMP(date) + 11644473600) * 10000000),"
489  " price,"
490  " price,"
491  " price,"
492  " amtEntered,"
493  " COUNT(DISTINCT typeID)"
494  " FROM mktData");
495 }
#define sDatabase
Definition: dbcore.h:199
Definition: dbcore.h:39
void MarketDB::UpdateInvPrice ( std::map< uint16, Inv::TypeData > &  data)
static

Definition at line 570 of file MarketDB.cpp.

References sDatabase, and sLog.

Referenced by MarketMgr::GetCruPrices(), and MarketMgr::SetBasePrice().

571 {
572  DBerror err;
573  for (auto cur : data) {
574  if (cur.second.basePrice < 0.01) {
575  sLog.Error(" SetBasePrice", "Calculated price for %s(%u) is 0", \
576  cur.second.name.c_str(), cur.first);
577  } else {
578  sDatabase.RunQuery(err, "UPDATE invTypes SET basePrice=%f WHERE typeID= %u", cur.second.basePrice, cur.first);
579  }
580  }
581 }
#define sDatabase
Definition: dbcore.h:199
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
Definition: dbcore.h:39

Here is the caller graph for this function:

void MarketDB::UpdateMktPrice ( std::map< uint16, Market::matlData > &  data)
static

Definition at line 583 of file MarketDB.cpp.

References sDatabase.

Referenced by MarketMgr::UpdateMineralPrice().

584 {
585  DBerror err;
586  for (auto cur : data)
587  sDatabase.RunQuery(err, "UPDATE invTypes SET basePrice=%f WHERE typeID= %u", cur.second.price, cur.first);
588 }
#define sDatabase
Definition: dbcore.h:199
Definition: dbcore.h:39

Here is the caller graph for this function:


The documentation for this class was generated from the following files: