Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
anis
anis-next
Commits
bab1e74d
Commit
bab1e74d
authored
Apr 27, 2022
by
François Agneray
Browse files
Fixed bug types (float, datatable null)
parent
569e1d06
Changes
5
Hide whitespace changes
Inline
Side-by-side
client/src/app/instance/search/components/result/datatable.component.html
View file @
bab1e74d
...
...
@@ -41,7 +41,7 @@
</button>
</td>
<td
*ngFor=
"let attribute of getOutputList()"
class=
"align-middle"
>
<div
*ngIf=
"datum[attribute.label]"
[ngSwitch]=
"attribute.renderer"
>
<div
*ngIf=
"datum[attribute.label]
!= null
"
[ngSwitch]=
"attribute.renderer"
>
<div
*ngSwitchCase=
"'detail-link'"
>
<app-detail-link-renderer
[value]=
"datum[attribute.label]"
...
...
client/src/app/instance/store/effects/archive.effects.ts
View file @
bab1e74d
...
...
@@ -107,7 +107,11 @@ export class ArchiveEffects {
resetArchive$
=
createEffect
(()
=>
this
.
actions$
.
pipe
(
ofType
(
archiveActions
.
resetArchive
),
tap
(()
=>
this
.
kill$
.
unsubscribe
())
tap
(()
=>
{
if
(
this
.
kill$
)
{
this
.
kill$
.
unsubscribe
();
}
})
),
{
dispatch
:
false
}
);
...
...
conf-dev/dev-php.ini
View file @
bab1e74d
...
...
@@ -13,7 +13,8 @@ max_input_time = 60
[xdebug]
zend_extension
=
/usr/local/lib/php/extensions/no-debug-non-zts-20210902/xdebug.so
xdebug.mode
=
debug
xdebug.default_enable
=
1
xdebug.mode
=
develop,debug
xdebug.client_host
=
127.0.0.1
xdebug.client_port
=
"9003"
...
...
server/src/Search/Response/JsonResponse.php
View file @
bab1e74d
...
...
@@ -32,14 +32,15 @@ class JsonResponse implements IResponse
*/
public
function
getResponse
(
ResponseInterface
$response
,
AnisQueryBuilder
$anisQueryBuilder
):
ResponseInterface
{
$stmt
=
$anisQueryBuilder
->
getDoctrineQueryBuilder
()
->
execute
();
$stmt
=
$anisQueryBuilder
->
getDoctrineQueryBuilder
()
->
execute
Query
();
$attributes
=
$anisQueryBuilder
->
getAttributesSelected
();
$payload
=
json_encode
(
$this
->
decodeNestedJson
(
$stmt
,
$attributes
),
JSON_UNESCAPED_SLASHES
);
$payload
=
json_encode
(
$this
->
processesTypes
(
$stmt
,
$attributes
),
JSON_UNESCAPED_SLASHES
);
$response
->
getBody
()
->
write
(
$payload
);
return
$response
;
}
/**
* Process types like float
* Decode each nsted json result and returns array results
*
* @param Result $stmt The doctrine statement of the query request
...
...
@@ -47,34 +48,21 @@ class JsonResponse implements IResponse
*
* @return array
*/
private
function
decodeNestedJson
(
Result
$stmt
,
array
$attributes
):
array
private
function
processesTypes
(
Result
$stmt
,
array
$attributes
):
array
{
$rows
=
array
();
$jsonAttributes
=
$this
->
getAttributesOfTypeJson
(
$attributes
);
while
(
$row
=
$stmt
->
fetch
(
\
PDO
::
FETCH_ASSOC
))
{
foreach
(
$row
as
$key
=>
$column
)
{
if
(
array_search
(
$key
,
$jsonAttributes
)
!==
false
&&
!
is_null
(
$column
))
{
$row
[
$key
]
=
json_decode
(
$column
,
true
);
while
(
$row
=
$stmt
->
fetchAssociative
())
{
foreach
(
$attributes
as
$attribute
)
{
$value
=
$row
[
$attribute
->
getLabel
()];
if
(
$attribute
->
getType
()
===
'json'
&&
!
is_null
(
$value
))
{
$row
[
$attribute
->
getLabel
()]
=
json_decode
(
$value
,
true
);
}
if
(
$attribute
->
getType
()
===
'float'
&&
!
is_null
(
$value
))
{
$row
[
$attribute
->
getLabel
()]
=
floatval
(
$value
);
}
}
$rows
[]
=
$row
;
}
return
$rows
;
}
/**
* Returns array of attributes label for the attribute type json
*
* @param Attribute[] $attributes The query attributes selected
*
* @return string[]
*/
private
function
getAttributesOfTypeJson
(
array
$attributes
):
array
{
return
array_map
(
function
(
$attribute
)
{
return
$attribute
->
getLabel
();
},
array_filter
(
$attributes
,
function
(
$attribute
)
{
return
$attribute
->
getType
()
===
'json'
;
}));
}
}
server/tests/Search/Response/JsonResponseTest.php
View file @
bab1e74d
...
...
@@ -25,7 +25,7 @@ final class JsonResponseTest extends TestCase
public
function
testGetResponse
():
void
{
$stmt
=
$this
->
getResultMock
();
$stmt
->
method
(
'fetch'
)
->
willReturnOnConsecutiveCalls
(
array
(
$stmt
->
method
(
'fetch
Associative
'
)
->
willReturnOnConsecutiveCalls
(
array
(
'id'
=>
1
,
'ra'
=>
102.5
,
'dec'
=>
0.1
,
...
...
@@ -34,19 +34,22 @@ final class JsonResponseTest extends TestCase
$id
=
$this
->
getAttributeMock
();
$id
->
method
(
'getLabel'
)
->
willReturn
(
'id'
);
$id
->
method
(
'getType'
)
->
willReturn
(
'integer'
);
$ra
=
$this
->
getAttributeMock
();
$ra
->
method
(
'getLabel'
)
->
willReturn
(
'ra'
);
$ra
->
method
(
'getType'
)
->
willReturn
(
'float'
);
$dec
=
$this
->
getAttributeMock
();
$dec
->
method
(
'getLabel'
)
->
willReturn
(
'dec'
);
$dec
=
$this
->
getAttributeMock
();
$dec
->
method
(
'getLabel'
)
->
willReturn
(
'json'
);
$dec
->
method
(
'getType'
)
->
willReturn
(
'json'
);
$dec
->
method
(
'getType'
)
->
willReturn
(
'float'
);
$json
=
$this
->
getAttributeMock
();
$json
->
method
(
'getLabel'
)
->
willReturn
(
'json'
);
$json
->
method
(
'getType'
)
->
willReturn
(
'json'
);
$doctrineQueryBuilder
=
$this
->
getDoctrineQueryBuilderMock
();
$doctrineQueryBuilder
->
method
(
'execute'
)
->
willReturn
(
$stmt
);
$doctrineQueryBuilder
->
method
(
'execute
Query
'
)
->
willReturn
(
$stmt
);
$anisQueryBuilder
=
$this
->
getAnisQueryBuilderMock
();
$anisQueryBuilder
->
method
(
'getDoctrineQueryBuilder'
)
->
willReturn
(
$doctrineQueryBuilder
);
$anisQueryBuilder
->
method
(
'getAttributesSelected'
)
->
willReturn
(
array
(
$id
,
$ra
,
$dec
));
$anisQueryBuilder
->
method
(
'getAttributesSelected'
)
->
willReturn
(
array
(
$id
,
$ra
,
$dec
,
$json
));
$textResponse
=
new
JsonResponse
();
$r
=
new
Response
(
200
,
array
(
...
...
Write
Preview
Supports
Markdown
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