Code Duplication    Length = 15-21 lines in 4 locations

include/classes/roundstats.class.php 4 locations

@@ 121-141 (lines=21) @@
118
   * @param height int Block Height
119
   * @return data array Block information from DB
120
   **/
121
  public function getPPLNSRoundStatsForAccounts($iHeight=0) {
122
    $stmt = $this->mysqli->prepare("
123
      SELECT
124
        a.username,
125
        a.is_anonymous,
126
        s.pplns_valid,
127
        s.pplns_invalid
128
        FROM " . $this->statistics->getTableName() . " AS s
129
        LEFT JOIN " . $this->block->getTableName() . " AS b ON s.block_id = b.id
130
        LEFT JOIN " . $this->user->getTableName() . " AS a ON a.id = s.account_id
131
        WHERE b.height = ? AND s.pplns_valid > 0
132
        GROUP BY username ASC
133
        ORDER BY pplns_valid DESC
134
        ");
135
    if ($this->checkStmt($stmt) && $stmt->bind_param('i', $iHeight) && $stmt->execute() && $result = $stmt->get_result())
136
      return $result->fetch_all(MYSQLI_ASSOC);
137
    return $this->sqlError();
138
  }
139
140
  /**
141
   * Get total valid pplns shares for block height
142
   **/
143
  public function getPPLNSRoundShares($iHeight=0) {
144
    $stmt = $this->mysqli->prepare("
@@ 143-157 (lines=15) @@
140
  /**
141
   * Get total valid pplns shares for block height
142
   **/
143
  public function getPPLNSRoundShares($iHeight=0) {
144
    $stmt = $this->mysqli->prepare("
145
      SELECT
146
        SUM(s.pplns_valid) AS pplns_valid
147
        FROM " . $this->statistics->getTableName() . " AS s
148
        LEFT JOIN " . $this->block->getTableName() . " AS b ON s.block_id = b.id
149
        WHERE b.height = ?
150
        ");
151
    if ($this->checkStmt($stmt) && $stmt->bind_param('i', $iHeight) && $stmt->execute() && $result = $stmt->get_result())
152
      return $result->fetch_object()->pplns_valid;
153
    return $this->sqlError();
154
  }
155
156
  /**
157
   * Get all transactions for round block height for admin
158
   * @param height int Block Height
159
   * @return data array Block round transactions
160
   **/
@@ 225-240 (lines=16) @@
222
  /**
223
   * Get USER last blocks from height for admin panel
224
   **/
225
  public function getUserReportBlocksFoundHeight($iHeight=0, $limit=10, $iUser) {
226
    $stmt = $this->mysqli->prepare("
227
      SELECT
228
        b.height, b.shares
229
        FROM " . $this->block->getTableName() . " AS b
230
        LEFT JOIN " . $this->statistics->getTableName() . " AS s ON s.block_id = b.id
231
        LEFT JOIN " . $this->user->getTableName() . " AS a ON a.id = s.account_id 
232
      WHERE b.height <= ? AND a.id = ?
233
      ORDER BY height DESC LIMIT ?");
234
    if ($this->checkStmt($stmt) && $stmt->bind_param('iii', $iHeight, $iUser, $limit) && $stmt->execute() && $result = $stmt->get_result())
235
      return $result->fetch_all(MYSQLI_ASSOC);
236
    return $this->sqlError();
237
  }
238
239
  /**
240
   * Get shares for block height for user admin panel
241
   **/
242
  public function getRoundStatsForUser($iHeight=0, $iUser) {
243
    $stmt = $this->mysqli->prepare("
@@ 242-259 (lines=18) @@
239
  /**
240
   * Get shares for block height for user admin panel
241
   **/
242
  public function getRoundStatsForUser($iHeight=0, $iUser) {
243
    $stmt = $this->mysqli->prepare("
244
      SELECT
245
        s.valid,
246
        s.invalid,
247
        s.pplns_valid,
248
        s.pplns_invalid
249
        FROM " . $this->statistics->getTableName() . " AS s
250
        LEFT JOIN " . $this->block->getTableName() . " AS b ON s.block_id = b.id
251
        LEFT JOIN " . $this->user->getTableName() . " AS a ON a.id = s.account_id
252
        WHERE b.height = ? AND a.id = ?");
253
    if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $iHeight, $iUser) && $stmt->execute() && $result = $stmt->get_result())
254
      return $result->fetch_assoc();
255
    return $this->sqlError();
256
  }
257
258
  /**
259
   * Get credit transactions for round block height for admin panel
260
   **/
261
  public function getUserRoundTransHeight($iHeight=0, $iUser) {
262
    $this->debug->append("STA " . __METHOD__, 4);