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
225
Issues
225
List
Boards
Labels
Service Desk
Milestones
Merge Requests
36
Merge Requests
36
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
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
Compare Revisions
3cff4b9037521a0999a7b51c11d6a5fd6cca4cc2...f310dde2e50783d405612e793596f85b8e13bb47
Source
f310dde2e50783d405612e793596f85b8e13bb47
Select Git revision
...
Target
3cff4b9037521a0999a7b51c11d6a5fd6cca4cc2
Select Git revision
Compare
Commits (2)
(fix): import and PHPDoc
· cc104246
Marcelo Rivera
authored
8 minutes ago
cc104246
(fix): correctly hydrate entities
· f310dde2
Marcelo Rivera
authored
7 minutes ago
f310dde2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
146 additions
and
2 deletions
+146
-2
Test.php.orig
Controllers/Cli/Test.php.orig
+137
-0
Manager.php
Core/Permissions/Manager.php
+9
-2
No files found.
Controllers/Cli/Test.php.orig
0 → 100644
View file @
f310dde2
<?php
namespace
Minds\Controllers\Cli
;
use
Minds\Cli
;
use
Minds\Core
;
use
Minds\Core\Data\ElasticSearch
;
use
Minds\Core\Di\Di
;
use
Minds\Interfaces
;
class
Test
extends
Cli\Controller
implements
Interfaces\CliControllerInterface
{
public
function
__construct
()
{
define
(
'__MINDS_INSTALLING__'
,
true
);
}
public
function
help
(
$command
=
null
)
{
$this
->
out
(
'TBD'
);
}
public
function
exec
()
{
$client
=
Di
::
_
()
->
get
(
'Database\ElasticSearch'
);
$query
=
[
'index'
=>
'minds-boost-campaigns'
,
//'type' => 'activity',
'_source'
=>
true
,
'size'
=>
100
,
'body'
=>
[
'query'
=>
[
'bool'
=>
[
'must_not'
=>
[
[
'exists'
=>
[
'field'
=>
'@completed'
,
],
],
[
'exists'
=>
[
'field'
=>
'@rejected'
,
],
],
[
'exists'
=>
[
'field'
=>
'@revoked'
,
],
],
],
'filter'
=>
[
'script'
=>
[
'script'
=>
[
"inline"
=>
"
if(doc._index.value == 'minds-boost')
return true;
ZonedDateTime start = ZonedDateTime.ofInstant(doc.start.value.toInstant(), ZoneId.systemDefault());
ZonedDateTime end = ZonedDateTime.ofInstant(doc.end.value.toInstant(), ZoneId.systemDefault());
def totalAmountOfDays = ChronoUnit.DAYS.between(start, end);
def impressionsPerDay = doc.impressions.value / totalAmountOfDays;
ZonedDateTime now = ZonedDateTime.ofInstant(Instant.ofEpochMilli(params.nowMillis), ZoneId.systemDefault());
def passedDays = ChronoUnit.DAYS.between(now, end);
def impressionsMetPerDay = (doc.impressions_met.value ?: doc.impressions.value) / passedDays;
Debug.explain(impressionsPerDay);
return impressionsMetPerDay <= impressionsPerDay;
"
,
'lang'
=>
'painless'
,
'params'
=>
[
'nowMillis'
=>
time
()
*
1000
,
],
],
],
],
],
],
],
];
$prepared
=
new
ElasticSearch\Prepared\Search
();
$prepared
->
query
(
$query
);
try
{
$result
=
$client
->
request
(
$prepared
);
var_dump
(
$result
);
}
catch
(
\Exception
$e
)
{
var_dump
(
str_replace
(
"
\\
n"
,
"
\r\n
"
,
$e
->
getMessage
()));
}
<<<<<<<
Updated
upstream
$this
->
out
(
$namespace
);
=======
// var_dump($result);
// die();
>>>>>>>
Stashed
changes
}
private
function
getTrendingActivities
()
{
$result
=
Core\Di\Di
::
_
()
->
get
(
'Trending\Repository'
)
->
getList
([
'type'
=>
'newsfeed'
,
'limit'
=>
12
,
]);
ksort
(
$result
[
'guids'
]);
$options
[
'guids'
]
=
$result
[
'guids'
];
$activities
=
Core\Entities
::
get
(
array_merge
([
<<<<<<<
Updated
upstream
'type'
=>
'activity'
],
$options
));
=======
'type'
=>
'activity'
,
]
,
$options
));
>>>>>>>
Stashed
changes
$activities
=
array_filter
(
$activities
,
function
(
$activity
)
{
if
(
$activity
->
paywall
)
{
return
false
;
}
if
(
$activity
->
remind_object
&&
$activity
->
remind_object
[
'paywall'
])
{
return
false
;
}
return
true
;
});
return
$activities
;
}
}
This diff is collapsed.
Click to expand it.
Core/Permissions/Manager.php
View file @
f310dde2
...
...
@@ -10,6 +10,7 @@ use Minds\Core\Permissions\Roles\Roles;
/*
* Manager for managing role based permissions
*/
class
Manager
{
/** @var EntitiesBuilder */
...
...
@@ -43,9 +44,15 @@ class Manager
throw
new
\InvalidArgumentException
(
'user_guid is required'
);
}
$guids
=
$opts
[
'guids'
]
?:
array_map
(
function
(
$item
)
{
return
$item
[
'guid'
];
},
$opts
[
'entities'
]);
$user
=
$this
->
entitiesBuilder
->
single
(
$opts
[
'user_guid'
]);
$entities
=
$this
->
entitiesBuilder
->
get
(
$opts
)
?:
[];
$entities
=
$this
->
entitiesBuilder
->
get
([
'guids'
=>
$guids
]);
if
(
!
$user
)
{
throw
new
\InvalidArgumentException
(
'User does not exist'
);
}
if
(
$user
&&
$user
->
getType
()
!==
'user'
)
{
throw
new
\InvalidArgumentException
(
'Entity is not a user'
);
}
...
...
This diff is collapsed.
Click to expand it.