Skip to content

Commit 2c17c33

Browse files
committed
Code cleaning and fixes
clean 2
1 parent 2d906e4 commit 2c17c33

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

factory/ideas.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public function get_ideas($number = 10, $sort = 'date', $sort_direction = 'DESC'
168168
{
169169
$sql = 'SELECT COUNT(i.idea_id) as num_ideas
170170
FROM ' . $this->table_ideas . ' i
171-
INNER JOIN ' . $this->table_topics . " t
171+
INNER JOIN ' . $this->table_topics . " t
172172
ON i.topic_id = t.topic_id
173173
WHERE $where";
174174
$result = $this->db->sql_query($sql);
@@ -183,7 +183,7 @@ public function get_ideas($number = 10, $sort = 'date', $sort_direction = 'DESC'
183183
{
184184
$sql = 'SELECT t.topic_last_post_time, t.topic_status, t.topic_visibility, i.*
185185
FROM ' . $this->table_ideas . ' i
186-
INNER JOIN ' . $this->table_topics . " t
186+
INNER JOIN ' . $this->table_topics . " t
187187
ON i.topic_id = t.topic_id
188188
WHERE $where
189189
ORDER BY " . $this->db->sql_escape($sortby);
@@ -196,12 +196,12 @@ public function get_ideas($number = 10, $sort = 'date', $sort_direction = 'DESC'
196196
((i.idea_votes_up + 1.9208) / (i.idea_votes_up + i.idea_votes_down) -
197197
1.96 * SQRT((i.idea_votes_up * i.idea_votes_down) / (i.idea_votes_up + i.idea_votes_down) + 0.9604) /
198198
(i.idea_votes_up + i.idea_votes_down)) / (1 + 3.8416 / (i.idea_votes_up + i.idea_votes_down))
199-
AS ci_lower_bound
200-
FROM ' . $this->table_ideas . ' i
201-
INNER JOIN ' . $this->table_topics . " t
202-
ON i.topic_id = t.topic_id
203-
WHERE $where
204-
ORDER BY ci_lower_bound " . $this->db->sql_escape($sort_direction);
199+
AS ci_lower_bound
200+
FROM ' . $this->table_ideas . ' i
201+
INNER JOIN ' . $this->table_topics . " t
202+
ON i.topic_id = t.topic_id
203+
WHERE $where
204+
ORDER BY ci_lower_bound " . $this->db->sql_escape($sort_direction);
205205
}
206206

207207
$result = $this->db->sql_query_limit($sql, $number, $start);
@@ -210,10 +210,7 @@ public function get_ideas($number = 10, $sort = 'date', $sort_direction = 'DESC'
210210

211211
if (count($rows))
212212
{
213-
$topic_ids = array_map(function($row) {
214-
return $row['topic_id'];
215-
}, $rows);
216-
213+
$topic_ids = array_column($rows, 'topic_id');
217214
$idea_ids = array_column($rows, 'idea_id');
218215

219216
$topic_tracking_info = get_complete_topic_tracking((int) $this->config['ideas_forum_id'], $topic_ids);
@@ -224,6 +221,7 @@ public function get_ideas($number = 10, $sort = 'date', $sort_direction = 'DESC'
224221
$row['read'] = !(isset($topic_tracking_info[$row['topic_id']]) && $row['topic_last_post_time'] > $topic_tracking_info[$row['topic_id']]);
225222
$row['u_voted'] = isset($user_voting_info[$row['idea_id']]) ? (string) $user_voting_info[$row['idea_id']] : '';
226223
}
224+
unset ($row);
227225
}
228226

229227
return $rows;
@@ -725,7 +723,7 @@ public function delete_orphans()
725723
{
726724
// Find any orphans
727725
$sql = 'SELECT idea_id FROM ' . $this->table_ideas . '
728-
WHERE topic_id NOT IN (SELECT t.topic_id
726+
WHERE topic_id NOT IN (SELECT t.topic_id
729727
FROM ' . $this->table_topics . ' t
730728
WHERE t.forum_id = ' . (int) $this->config['ideas_forum_id'] . ')';
731729
$result = $this->db->sql_query($sql);

0 commit comments

Comments
 (0)