forked from La_Bureautique/zeg1jeux
Ajout ratings gchange
This commit is contained in:
parent
5917c74e4e
commit
7c87c4a371
|
@ -75,7 +75,7 @@ class DAO {
|
||||||
|
|
||||||
'duniter' => 2,
|
'duniter' => 2,
|
||||||
'cesiumplus' => 5,
|
'cesiumplus' => 5,
|
||||||
'gchange' => 5,
|
'gchange' => 10,
|
||||||
];
|
];
|
||||||
|
|
||||||
private $nodeTimeoutIncrement = [
|
private $nodeTimeoutIncrement = [
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
require_once('DAO.class.php');
|
require_once('DAO.class.php');
|
||||||
require_once('GchangeUser.class.php');
|
require_once('GchangeUser.class.php');
|
||||||
require_once('GchangeRecord.class.php');
|
require_once('GchangeRecord.class.php');
|
||||||
|
require_once('GchangeRating.class.php');
|
||||||
|
|
||||||
class Gchange {
|
class Gchange {
|
||||||
|
|
||||||
|
@ -291,6 +292,70 @@ class Gchange {
|
||||||
return $users;
|
return $users;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRatingsSentBy ($issuer) {
|
||||||
|
|
||||||
|
$n = 20;
|
||||||
|
|
||||||
|
$queryParams = [
|
||||||
|
'size' => $n,
|
||||||
|
'query' => [
|
||||||
|
'bool' => [
|
||||||
|
'must' => [
|
||||||
|
'term' => ['kind' => 'STAR']
|
||||||
|
],
|
||||||
|
'filter' => [
|
||||||
|
'term' => ['issuer' => $issuer]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
$json = $this->dao->fetchJson('/like/record/_search', 'gchange', $queryParams);
|
||||||
|
|
||||||
|
$result = json_decode($json);
|
||||||
|
|
||||||
|
$ratings = [];
|
||||||
|
|
||||||
|
foreach ($result->hits->hits as $hit) {
|
||||||
|
|
||||||
|
$ratings[] = new GchangeRating($hit);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ratings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRatingsReceivedBy ($receiver) {
|
||||||
|
|
||||||
|
$n = 20;
|
||||||
|
|
||||||
|
$queryParams = [
|
||||||
|
'size' => $n,
|
||||||
|
'query' => [
|
||||||
|
'bool' => [
|
||||||
|
'must' => [
|
||||||
|
'term' => ['kind' => 'STAR']
|
||||||
|
],
|
||||||
|
'filter' => [
|
||||||
|
'term' => ['id' => $receiver]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
$json = $this->dao->fetchJson('/like/record/_search', 'gchange', $queryParams);
|
||||||
|
|
||||||
|
$result = json_decode($json);
|
||||||
|
|
||||||
|
$ratings = [];
|
||||||
|
|
||||||
|
foreach ($result->hits->hits as $hit) {
|
||||||
|
|
||||||
|
$ratings[] = new GchangeRating($hit);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ratings;
|
||||||
|
}
|
||||||
|
|
||||||
public function getNearbyPlacesJson ($lat, $lon, $maxDistance, $minDistance = NULL) {
|
public function getNearbyPlacesJson ($lat, $lon, $maxDistance, $minDistance = NULL) {
|
||||||
|
|
||||||
$n = 20;
|
$n = 20;
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class GchangeRating {
|
||||||
|
|
||||||
|
private $senderPubkey;
|
||||||
|
|
||||||
|
private $receiverPubkey;
|
||||||
|
|
||||||
|
private $level;
|
||||||
|
|
||||||
|
private $time;
|
||||||
|
|
||||||
|
|
||||||
|
public function __construct ($gchangeObject) {
|
||||||
|
|
||||||
|
$this->senderPubkey = $gchangeObject->_source->issuer;
|
||||||
|
|
||||||
|
$this->receiverPubkey = $gchangeObject->_source->id;
|
||||||
|
|
||||||
|
$this->level = $gchangeObject->_source->level;
|
||||||
|
|
||||||
|
$this->time = $gchangeObject->_source->time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLevel () {
|
||||||
|
|
||||||
|
return $this->level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSenderPubkey () {
|
||||||
|
|
||||||
|
return $this->senderPubkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getReceiverPubkey () {
|
||||||
|
|
||||||
|
return $this->receiverPubkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTime () {
|
||||||
|
|
||||||
|
return $this->time;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue