Skip to content
Commits on Source (15)
......@@ -65,7 +65,11 @@ class scheduled implements Interfaces\Api
return Factory::response([
'status' => 'success',
'count' => $manager->getScheduledCount(['container_guid' => $container_guid, 'type' => $type])
'count' => $manager->getScheduledCount([
'container_guid' => $container_guid,
'type' => $type,
'owner_guid' => $currentUser->guid,
])
]);
default:
return Factory::response([
......@@ -148,6 +152,7 @@ class scheduled implements Interfaces\Api
'single_owner_threshold' => 0,
'pinned_guids' => $type === 'activity' ? array_reverse($container->getPinnedPosts()) : null,
'time_created_upper' => false,
'owner_guid' => $currentUser->guid,
];
if (isset($_GET['nsfw'])) {
......
......@@ -4,6 +4,7 @@ namespace Minds\Core\Analytics\Dashboards;
class Manager
{
const DASHBOARDS = [
'summary' => SummaryDashboard::class,
'traffic' => TrafficDashboard::class,
'trending' => TrendingDashboard::class,
'earnings' => EarningsDashboard::class,
......
<?php
/**
* Summary Dashboard
*/
namespace Minds\Core\Analytics\Dashboards;
use Minds\Entities\User;
use Minds\Traits\MagicAttributes;
/**
* @method TrafficDashboard setTimespanId(string $timespanId)
* @method TrafficDashboard setFilterIds(array $filtersIds)
* @method TrafficDashboard setUser(User $user)
*/
class SummaryDashboard implements DashboardInterface
{
use MagicAttributes;
/** @var string */
private $timespanId = '30d';
/** @var string[] */
private $filterIds = [ 'platform::browser' ];
/** @var string */
private $metricId = 'active_users';
/** @var Timespans\TimespansCollection */
private $timespansCollection;
/** @var Metrics\MetricsCollection */
private $metricsCollection;
/** @var Filters\FiltersCollection */
private $filtersCollection;
/** @var User */
private $user;
public function __construct(
$timespansCollection = null,
$metricsCollection = null,
$filtersCollection = null
) {
$this->timespansCollection = $timespansCollection ?? new Timespans\TimespansCollection();
$this->metricsCollection = $metricsCollection ?? new Metrics\MetricsCollection();
$this->filtersCollection = $filtersCollection ?? new Filters\FiltersCollection();
}
/**
* Build the dashboard
* @return self
*/
public function build(): self
{
$this->timespansCollection
->setSelectedId($this->timespanId)
->addTimespans(
new Timespans\TodayTimespan(),
new Timespans\_30dTimespan(),
new Timespans\_1yTimespan(),
new Timespans\MtdTimespan(),
new Timespans\YtdTimespan()
);
$this->filtersCollection
->setSelectedIds($this->filterIds)
->setUser($this->user)
->addFilters(
// new Filters\PlatformFilter(),
new Filters\ViewTypeFilter(),
new Filters\ChannelFilter()
);
$this->metricsCollection
->setTimespansCollection($this->timespansCollection)
->setFiltersCollection($this->filtersCollection)
->setSelectedId($this->metricId)
->setUser($this->user)
->addMetrics(
new Metrics\ActiveUsersMetric()
)
->build();
return $this;
}
/**
* Export
* @param array $extras
* @return array
*/
public function export(array $extras = []): array
{
$this->build();
return [
'category' => 'summary',
'label' => 'Summary',
'description' => null,
'timespan' => $this->timespansCollection->getSelected()->getId(),
'timespans' => $this->timespansCollection->export(),
'metric' => $this->metricsCollection->getSelected()->getId(),
'metrics' => $this->metricsCollection->export(),
'filter' => $this->filtersCollection->getSelectedIds(),
'filters' => $this->filtersCollection->export(),
];
}
}
<?php
/**
* @author: eiennohi.
*/
namespace Minds\Core\Channels\Delegates;
use Minds\Core\Analytics\Metrics\Event;
use Minds\Entities\User;
class MetricsDelegate
{
public function onDelete(User $user)
{
$event = new Event();
$event->setType('action')
->setAction('delete')
->setProduct('platform')
->setUserGuid((string) $user->guid)
->setUserPhoneNumberHash($user->getPhoneNumberHash())
->push();
}
}
......@@ -5,6 +5,7 @@
namespace Minds\Core\Channels;
use Minds\Core\Channels\Delegates\MetricsDelegate;
use Minds\Core\Di\Di;
use Minds\Core\Queue\Interfaces\QueueClient;
use Minds\Entities\User;
......@@ -30,6 +31,9 @@ class Manager
/** @var Delegates\Artifacts\Factory */
protected $artifactsDelegatesFactory;
/** @var MetricsDelegate */
protected $metricsDelegate;
/** @var Delegates\Logout */
protected $logoutDelegate;
......@@ -44,10 +48,12 @@ class Manager
*/
public function __construct(
$artifactsDelegatesFactory = null,
$metricsDelegate = null,
$logoutDelegate = null,
$queueClient = null
) {
$this->artifactsDelegatesFactory = $artifactsDelegatesFactory ?: new Delegates\Artifacts\Factory();
$this->metricsDelegate = $metricsDelegate ?: new MetricsDelegate();
$this->logoutDelegate = $logoutDelegate ?: new Delegates\Logout();
$this->queueClient = $queueClient ?: Di::_()->get('Queue');
}
......@@ -139,6 +145,7 @@ class Manager
}
}
$this->metricsDelegate->onDelete($this->user);
$this->logoutDelegate->logout($this->user);
return true;
......
......@@ -9,6 +9,7 @@ use Minds\Entities\RepositoryEntity;
use Minds\Entities\User;
use Minds\Helpers\Flags;
use Minds\Helpers\Unknown;
use Minds\Helpers\Export;
use Minds\Core\Di\Di;
/**
......@@ -406,6 +407,8 @@ class Comment extends RepositoryEntity
//$output['parent_guid'] = (string) $this->entityGuid;
$output = Export::sanitize($output);
return $output;
}
}
......@@ -28,6 +28,7 @@ class Repository
$opts = array_merge([
'container_guid' => null,
'type' => null,
'owner_guid' => null,
], $opts);
if (!$opts['type']) {
......@@ -64,6 +65,16 @@ class Repository
]
];
if ($opts['owner_guid']) {
$ownerGuids = Text::buildArray($opts['owner_guid']);
$query['body']['query']['bool']['must'][] = [
'terms' => [
'owner_guid' => $ownerGuids,
],
];
}
$prepared = new Prepared\Count();
$prepared->query($query);
......
......@@ -54,6 +54,7 @@ class FFMpeg implements ServiceInterface
'ffmpeg.binaries' => '/usr/bin/ffmpeg',
'ffprobe.binaries' => '/usr/bin/ffprobe',
'ffmpeg.threads' => $this->config->get('transcoder')['threads'],
'timeout' => 0,
]);
$this->ffprobe = $ffprobe ?: FFProbeClient::create([
'ffprobe.binaries' => '/usr/bin/ffprobe',
......@@ -253,19 +254,25 @@ class FFMpeg implements ServiceInterface
$pfx = ($rotated ? $opts['width'] : $opts['height']).'.'.$format;
$path = $sourcePath.'-'.$pfx;
try {
echo "\nTranscoding: $path ($this->key)";
echo "\nTranscoding: $path ($this->key)\n";
$formatMap[$format]->on('progress', function ($a, $b, $pct) {
echo "\r$pct% transcoded";
// also emit out to cassandra so frontend can keep track
});
$formatMap[$format]
->setKiloBitRate($opts['bitrate'])
->setAudioChannels(2)
// ->setAudioChannels(2)
->setAudioKiloBitrate($opts['audio_bitrate']);
$video->save($formatMap[$format], $path);
//now upload to s3
$this->uploadTranscodedFile($path, $pfx);
//cleanup tmp file
@unlink($path);
} catch (\Exception $e) {
echo " failed {$e->getMessage()}";
//cleanup tmp file
@unlink($path);
}
}
}
......
......@@ -69,6 +69,11 @@ class Repository
try {
$rows = $this->client->request($query);
if (!$rows) {
return $response;
}
foreach ($rows as $row) {
$user = new User($row['column1']);
$response[] = $user;
......
......@@ -153,7 +153,7 @@ class Image extends File
$w = 1024;
$s = false;
$u = true;
// no break
break;
default:
continue 2;
}
......
......@@ -20,6 +20,9 @@ class ManagerSpec extends ObjectBehavior
/** @var Delegates\Artifacts\Factory */
protected $artifactsDelegatesFactory;
/** @var Delegates\MetricsDelegate */
protected $metricsDelegate;
/** @var Delegates\Logout */
protected $logoutDelegate;
......@@ -28,16 +31,19 @@ class ManagerSpec extends ObjectBehavior
public function let(
Delegates\Artifacts\Factory $artifactsDelegatesFactory,
Delegates\MetricsDelegate $metricsDelegate,
Delegates\Logout $logoutDelegate,
QueueClient $queueClient
) {
$this->beConstructedWith(
$artifactsDelegatesFactory,
$metricsDelegate,
$logoutDelegate,
$queueClient
);
$this->artifactsDelegatesFactory = $artifactsDelegatesFactory;
$this->metricsDelegate = $metricsDelegate;
$this->logoutDelegate = $logoutDelegate;
$this->queueClient = $queueClient;
}
......@@ -139,6 +145,9 @@ class ManagerSpec extends ObjectBehavior
->shouldBeCalledTimes(count($deletionDelegates))
->willReturn(true);
$this->metricsDelegate->onDelete($user)
->shouldBeCalled();
$this->logoutDelegate->logout($user)
->shouldBeCalled()
->willReturn(true);
......