Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bat_api
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
bat_api
Commits
ce0c69d3
Commit
ce0c69d3
authored
Feb 4, 2016
by
Adrian Rollett
Browse files
Options
Downloads
Patches
Plain Diff
Update events endpoint to handle generic targets
parent
999fee3e
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bat_api.module
+22
-14
22 additions, 14 deletions
bat_api.module
with
22 additions
and
14 deletions
bat_api.module
+
22
−
14
View file @
ce0c69d3
...
...
@@ -228,19 +228,26 @@ function bat_api_services_resources() {
'access arguments'
=>
array
(
'access events index service'
),
'args'
=>
array
(
array
(
'name'
=>
'
uni
t_ids'
,
'name'
=>
'
targe
t_ids'
,
'type'
=>
'string'
,
'description'
=>
t
(
'
Un
it IDs'
),
'source'
=>
array
(
'param'
=>
'
uni
t_ids'
),
'description'
=>
t
(
'
Targe Ent
it
y
IDs'
),
'source'
=>
array
(
'param'
=>
'
targe
t_ids'
),
'optional'
=>
FALSE
,
),
array
(
'name'
=>
'
uni
t_types'
,
'name'
=>
'
targe
t_types'
,
'type'
=>
'string'
,
'description'
=>
t
(
'
Uni
t Types'
),
'source'
=>
array
(
'param'
=>
'
uni
t_types'
),
'description'
=>
t
(
'
Targe
t Types'
),
'source'
=>
array
(
'param'
=>
'
targe
t_types'
),
'optional'
=>
TRUE
,
),
array
(
'name'
=>
'target_entity_type'
,
'type'
=>
'string'
,
'description'
=>
t
(
'Target Entity Type'
),
'source'
=>
array
(
'param'
=>
'target_entity_type'
),
'optional'
=>
FALSE
,
),
array
(
'name'
=>
'start_date'
,
'type'
=>
'string'
,
...
...
@@ -529,17 +536,18 @@ function bat_api_services_edit_unit($unit_id, $bat_unit_data) {
/**
* Retrieve a list of events.
*
* @param $unit_ids
* @param $unit_types
* @param $target_ids
* @param $target_types
* @param $target_entity_type
* @param $start_date
* @param $end_date
* @param $event_types
*/
function
bat_api_services_events_index
(
$
uni
t_ids
,
$
un
it_type
s
,
$start_date
,
$end_date
,
$event_types
)
{
function
bat_api_services_events_index
(
$
targe
t_ids
,
$
target_types
,
$target_ent
it
y
_type
,
$start_date
,
$end_date
,
$event_types
)
{
$return
=
new
stdClass
();
$return
->
sessid
=
session_id
();
$
uni
t_types
=
array_filter
(
explode
(
','
,
$
uni
t_types
));
$
targe
t_types
=
array_filter
(
explode
(
','
,
$
targe
t_types
));
$types
=
array_filter
(
explode
(
','
,
$event_types
));
...
...
@@ -561,12 +569,12 @@ function bat_api_services_events_index($unit_ids, $unit_types, $start_date, $end
$start_date_object
=
$today
;
}
$ids
=
explode
(
','
,
$
uni
t_ids
);
$ids
=
explode
(
','
,
$
targe
t_ids
);
$units
=
array
();
foreach
(
$ids
as
$id
)
{
if
(
$
bat_un
it
=
bat_un
it_load
(
$id
))
{
if
(
in_array
(
$
bat_un
it
->
type
,
$
uni
t_types
)
||
empty
(
$
uni
t_types
))
{
if
(
$
target_ent
it
y
=
ent
it
y
_load
_single
(
$target_entity_type
,
$id
))
{
if
(
in_array
(
$
target_ent
it
y
->
type
,
$
targe
t_types
)
||
empty
(
$
targe
t_types
))
{
// Setting the default value to 0 since we are dealing with the events array
// so getting event IDs.
$units
[]
=
new
Unit
(
$id
,
0
);
...
...
@@ -592,7 +600,7 @@ function bat_api_services_events_index($unit_ids, $unit_types, $start_date, $end
$events_json
[]
=
array
(
'id'
=>
(
string
)
$key
.
$unit_id
,
'bat_id'
=>
$event
->
getValue
(),
'resourceId'
=>
'S'
.
$
uni
t_id
,
'resourceId'
=>
'S'
.
$
targe
t_id
,
)
+
$event
->
toJson
(
$event_formatter
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment