...
 
Commits (8)
......@@ -24,6 +24,7 @@ class entities implements Interfaces\Api
public function get($pages)
{
$asActivities = (bool) ($_GET['as_activities'] ?? false);
$exportUserCounts = (bool) ($_GET['export_user_counts'] ?? false);
$urns = array_map([Urn::class, '_'], array_filter(explode(',', $_GET['urns'] ?? ''), [Urn::class, 'isValid']));
$resolver = new Resolver();
......@@ -31,11 +32,17 @@ class entities implements Interfaces\Api
->setUser(Session::getLoggedinUser() ?: null)
->setUrns($urns)
->setOpts([
'asActivities' => $asActivities
'asActivities' => $asActivities,
]);
$entities = $resolver->fetch();
if ($exportUserCounts) {
foreach ($entities as $user) {
$user->exportCounts = true;
}
}
// Return
return Factory::response([
'entities' => Exportable::_(array_values($entities)),
......
......@@ -8,6 +8,7 @@ use Minds\Common\Repository\Response;
use Minds\Core;
use Minds\Core\Di\Di;
use Minds\Entities\Factory as EntitiesFactory;
use Minds\Entities\Group;
use Minds\Entities\User;
use Minds\Interfaces;
......@@ -18,7 +19,7 @@ class feeds implements Interfaces\Api
'24h' => '7d',
'7d' => '30d',
'30d' => '1y',
'1y' => 'all'
'1y' => 'all',
];
/**
......@@ -41,7 +42,7 @@ class feeds implements Interfaces\Api
if (!$filter) {
return Factory::response([
'status' => 'error',
'message' => 'Invalid filter'
'message' => 'Invalid filter',
]);
}
......@@ -50,7 +51,7 @@ class feeds implements Interfaces\Api
if (!$algorithm) {
return Factory::response([
'status' => 'error',
'message' => 'Invalid algorithm'
'message' => 'Invalid algorithm',
]);
}
......@@ -84,6 +85,12 @@ class feeds implements Interfaces\Api
$period = '1y';
}
$exportCounts = false;
if (isset($_GET['export_user_counts'])) {
$exportCounts = true;
}
//
$hardLimit = 600;
......@@ -146,7 +153,7 @@ class feeds implements Interfaces\Api
if (!$container || !Core\Security\ACL::_()->read($container)) {
return Factory::response([
'status' => 'error',
'message' => 'Forbidden'
'message' => 'Forbidden',
]);
}
}
......@@ -240,6 +247,11 @@ class feeds implements Interfaces\Api
$entities = $entities->map([$elasticEntities, 'cast']);
}
}
if ($type === 'user' && $exportCounts) {
foreach ($entities as $entity) {
$entity->getEntity()->exportCounts = true;
}
}
return Factory::response([
'status' => 'success',
......
......@@ -47,9 +47,9 @@ class Unleash extends BaseService
$configValues = $this->config->get('unleash');
$config = new UnleashConfig(
$configValues['apiUrl'] ?? null,
$configValues['instanceId'] ?? null,
$configValues['applicationName'] ?? null,
getenv('UNLEASH_API_URL') ?: ($configValues['apiUrl'] ?? null),
getenv('UNLEASH_INSTANCE_ID') ?: ($configValues['instanceId'] ?? null),
getenv('MINDS_ENV') ?: ($configValues['applicationName'] ?? 'development'),
$configValues['pollingIntervalSeconds'] ?? null,
$configValues['metricsIntervalSeconds'] ?? null
);
......
......@@ -8,7 +8,7 @@
namespace Minds\Core\Feeds;
use JsonSerializable;
use Minds\Traits\Exportable;
use Minds\Entities\Entity;
use Minds\Traits\MagicAttributes;
/**
......@@ -22,6 +22,8 @@ use Minds\Traits\MagicAttributes;
* @method FeedSyncEntity setTimestamp(int $timestamp)
* @method string getUrn()
* @method FeedSyncEntity setUrn(string $urn)
* @method Entity getEntity()
* @method void setEntity(Entity $entity)
*/
class FeedSyncEntity implements JsonSerializable
{
......@@ -53,7 +55,7 @@ class FeedSyncEntity implements JsonSerializable
{
return [
'guid' => (string) $this->guid,
'owner_guid' => (string) $this->ownerGuid,
'owner_guid' => (string) $this->ownerGuid,
'timestamp' => $this->timestamp,
'urn' => $this->urn,
'entity' => $this->entity ? $this->entity->export() : null,
......