Permalink
Browse files

Add timestamp of statement and fact-check #1

  • Loading branch information...
KrzysztofMadejski committed Nov 7, 2018
1 parent af0a4b8 commit 1ec346d398e9a87c032bae606179621898a07c62
Showing with 8 additions and 1 deletion.
  1. +2 −0 model/Statement.php
  2. +2 −0 schemas/StatementSchema.php
  3. +4 −1 sites/DemagogPL.php
@@ -17,4 +17,6 @@ class Statement
public $explanation;
public $factchecker_uri;
public $sources;
public $timestamp_factcheck;
public $timestamp_statement;
}
@@ -28,6 +28,8 @@ public function getAttributes($statement)
'rating_img' => $statement->rating_img,
'explanation' => $statement->explanation,
'factchecker_uri' => $statement->factchecker_uri,
'timestamp_factcheck' => $statement->timestamp_factcheck,
'timestamp_statement' => $statement->timestamp_statement,
'sources' => $statement->sources,
];
}
@@ -54,6 +54,7 @@ public function get_statement($statement_id) {
$st = new Statement();
$st->id = $statement_id;
$st->factchecker_uri = get_site_url() . '?p=' . $post_and_statement_id[1];
$st->timestamp_factcheck = get_the_date('c', $post_and_statement_id[1]);
$statement_inpost_str = (string) $post_and_statement_id[2];
@@ -70,7 +71,7 @@ public function get_statement($statement_id) {
// get post metadata
$sql = 'select meta_key, meta_value FROM '. $wpdb->prefix .'postmeta where ' .
'post_id = ' . $post_and_statement_id[1] .
' AND LEFT(meta_key, '. (19 + strlen($statement_inpost_str)) .') = "politic_statement_'. $statement_inpost_str .'_";';
' AND (LEFT(meta_key, '. (19 + strlen($statement_inpost_str)) .') = "politic_statement_'. $statement_inpost_str .'_" OR meta_key = "date_statement" );';
$data = $wpdb->get_results($sql);
foreach ($data as $d) {
@@ -96,6 +97,8 @@ public function get_statement($statement_id) {
} else if (endsWith($d->meta_key, 'fc-source')) {
$sources[$d->meta_value] = 1;
} else if ($d->meta_key == 'date_statement') {
$st->timestamp_statement = substr_replace(substr_replace($d->meta_value, '-', 6, 0), '-', 4, 0);
}
}

0 comments on commit 1ec346d

Please sign in to comment.