feat: re-add post access counter for get_post function
This commit is contained in:
parent
226d19e62c
commit
edeecb8cf9
1 changed files with 16 additions and 2 deletions
|
@ -229,12 +229,26 @@ class MySQLAdapter {
|
|||
function get_post_by_path($post_path,
|
||||
$with_subposts = false, $with_settings = true) {
|
||||
|
||||
$qry = "SELECT * FROM posts WHERE post_path = ?";
|
||||
$qry = "
|
||||
WITH selected_post AS (
|
||||
SELECT *
|
||||
FROM posts WHERE post_path = ?
|
||||
), post_count_data AS (
|
||||
SELECT pac.post_path AS post_path, sum(path_access_count) AS post_access_counter
|
||||
FROM path_access_counts AS pac
|
||||
INNER JOIN selected_post ON pac.post_path = selected_post.post_path
|
||||
WHERE agent LIKE 'user%'
|
||||
GROUP BY pac.post_path
|
||||
)
|
||||
SELECT *
|
||||
FROM selected_post
|
||||
LEFT JOIN post_count_data ON post_count_data.post_path = selected_post.post_path";
|
||||
|
||||
$post_path = $this->_sanitize_path($post_path);
|
||||
|
||||
$post_data = $this->_exec($qry, "s", $post_path)->fetch_assoc();
|
||||
|
||||
$post_data = $this->_normalize_post_data($post_data);
|
||||
|
||||
$post_data['post_path'] = $post_path;
|
||||
|
||||
if(!$post_data['found']) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue