fixed comments count in citizen portal

This commit is contained in:
2026-04-28 15:15:33 +02:00
parent 879d7c5858
commit b18811c453
4 changed files with 87 additions and 8 deletions

View File

@@ -71,12 +71,12 @@ $news_items = $stmt->fetchAll();
// Loads Comments with Contribution for Moderation
$stmt = $pdo->prepare("
SELECT cm.comment_id, cm.contribution_id, cm.author_name, cm.browser_id, cm.content, cm.created_at,
co.title AS contribution_title
FROM comments cm
JOIN contributions co ON cm.contribution_id = co.contribution_id
WHERE co.municipality_id = :mid
ORDER BY cm.created_at DESC
SELECT contribution_id, title, category, description, author_name,
geom_type, status, likes_count, dislikes_count, comment_count,
photo_path, created_at, updated_at
FROM contributions
WHERE municipality_id = :mid
ORDER BY created_at DESC
");
$stmt->execute([':mid' => $municipality['municipality_id']]);
$all_comments = $stmt->fetchAll();

View File

@@ -83,8 +83,8 @@ function handle_read($input) {
$municipality_id = $input['municipality_id'];
// Builds SQL Query with Placeholders for prepared Statement
$sql = "SELECT *, ST_AsGeoJSON(geom) AS geojson
FROM contributions
$sql = "SELECT *, ST_AsGeoJSON(geom) AS geojson
FROM contributions
WHERE municipality_id = :mid";
$params = [':mid' => $municipality_id];