Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
220
Issues
220
List
Boards
Labels
Service Desk
Milestones
Merge Requests
30
Merge Requests
30
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
54fe5e28
Commit
54fe5e28
authored
42 minutes ago
by
Juan Manuel Solaro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(feat) ability to count scheduled activities
parent
d73a5a51
epic/post-scheduler
1 merge request
!294
WIP: epic/post-scheduler
Pipeline
#77592299
passed with stages
in 11 minutes and 24 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
111 additions
and
3 deletions
+111
-3
scheduled.php
Controllers/api/v2/channel/scheduled.php
+10
-2
Manager.php
Core/Feeds/Scheduled/Manager.php
+26
-0
Repository.php
Core/Feeds/Scheduled/Repository.php
+75
-0
Repository.php
Core/Feeds/Top/Repository.php
+0
-1
No files found.
Controllers/api/v2/channel/scheduled.php
View file @
54fe5e28
...
...
@@ -57,9 +57,17 @@ class scheduled implements Interfaces\Api
case
'blogs'
:
$type
=
'object:blog'
;
break
;
}
case
'count'
:
$type
=
'activity'
;
//
/** @var Core\Feeds\Scheduled\Manager $manager */
$manager
=
new
Core\Feeds\Scheduled\Manager
;
return
Factory
::
response
([
'status'
=>
'success'
,
'count'
=>
$manager
->
getScheduledCount
([
'container_guid'
=>
$container_guid
,
'type'
=>
$type
])
]);
}
$hardLimit
=
5000
;
$offset
=
0
;
...
...
This diff is collapsed.
Click to expand it.
Core/Feeds/Scheduled/Manager.php
0 → 100644
View file @
54fe5e28
<?php
namespace
Minds\Core\Feeds\Scheduled
;
class
Manager
{
/** @var Repository */
protected
$repository
;
public
function
__construct
(
$repository
=
null
)
{
$this
->
repository
=
$repository
?:
new
Repository
;
}
/**
* @param array $opts
* @return int
*/
public
function
getScheduledCount
(
array
$opts
=
[])
{
return
$this
->
repository
->
getScheduledCount
(
$opts
)
;
}
}
This diff is collapsed.
Click to expand it.
Core/Feeds/Scheduled/Repository.php
0 → 100644
View file @
54fe5e28
<?php
namespace
Minds\Core\Feeds\Scheduled
;
use
Minds\Core\Data\ElasticSearch\Client
as
ElasticsearchClient
;
use
Minds\Core\Data\ElasticSearch\Prepared
;
use
Minds\Core\Di\Di
;
use
Minds\Helpers\Text
;
class
Repository
{
/** @var ElasticsearchClient */
protected
$client
;
protected
$index
;
public
function
__construct
(
$client
=
null
,
$config
=
null
)
{
$this
->
client
=
$client
?:
Di
::
_
()
->
get
(
'Database\ElasticSearch'
);
$config
=
$config
?:
Di
::
_
()
->
get
(
'Config'
);
$this
->
index
=
$config
->
get
(
'elasticsearch'
)[
'index'
];
}
public
function
getScheduledCount
(
array
$opts
=
[])
{
$opts
=
array_merge
([
'container_guid'
=>
null
,
'type'
=>
null
,
],
$opts
);
if
(
!
$opts
[
'type'
])
{
throw
new
\Exception
(
'Type must be provided'
);
}
if
(
!
$opts
[
'container_guid'
])
{
throw
new
\Exception
(
'Container Guid must be provided'
);
}
$containerGuids
=
Text
::
buildArray
(
$opts
[
'container_guid'
]);
$query
=
[
'index'
=>
$this
->
index
,
'type'
=>
$opts
[
'type'
],
'body'
=>
[
'query'
=>
[
'bool'
=>
[
'must'
=>
[
[
'range'
=>
[
'time_created'
=>
[
'gt'
=>
time
(),
]
]
],
[
'terms'
=>
[
'container_guid'
=>
$containerGuids
,
],
]
]
]
]
]
];
$prepared
=
new
Prepared\Count
();
$prepared
->
query
(
$query
);
$result
=
$this
->
client
->
request
(
$prepared
);
return
$result
[
'count'
]
??
0
;
}
}
This diff is collapsed.
Click to expand it.
Core/Feeds/Top/Repository.php
View file @
54fe5e28
...
...
@@ -29,7 +29,6 @@ class Repository
/**
* @param array $opts
* @param bool $filter_by_created_time
* @return \Generator|ScoredGuid[]
* @throws \Exception
*/
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment