Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
3fc0b564
Commit
3fc0b564
authored
Aug 24, 2012
by
Nathan Bell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes Issue #108: provide start, end and gap values in facet range results
parent
5c7afe1c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
6 deletions
+86
-6
library/Solarium/Client/ResponseParser/Select/Component/FacetSet.php
...arium/Client/ResponseParser/Select/Component/FacetSet.php
+5
-2
library/Solarium/Result/Select/Facet/Range.php
library/Solarium/Result/Select/Facet/Range.php
+62
-2
tests/Solarium/Result/Select/Facet/RangeTest.php
tests/Solarium/Result/Select/Facet/RangeTest.php
+19
-2
No files found.
library/Solarium/Client/ResponseParser/Select/Component/FacetSet.php
View file @
3fc0b564
...
...
@@ -174,6 +174,9 @@ class Solarium_Client_ResponseParser_Select_Component_FacetSet
$before
=
(
isset
(
$data
[
'before'
]))
?
$data
[
'before'
]
:
null
;
$after
=
(
isset
(
$data
[
'after'
]))
?
$data
[
'after'
]
:
null
;
$between
=
(
isset
(
$data
[
'between'
]))
?
$data
[
'between'
]
:
null
;
$start
=
(
isset
(
$data
[
'start'
]))
?
$data
[
'start'
]
:
null
;
$end
=
(
isset
(
$data
[
'end'
]))
?
$data
[
'end'
]
:
null
;
$gap
=
(
isset
(
$data
[
'gap'
]))
?
$data
[
'gap'
]
:
null
;
$offset
=
0
;
$counts
=
array
();
...
...
@@ -182,8 +185,8 @@ class Solarium_Client_ResponseParser_Select_Component_FacetSet
$offset
+=
2
;
}
return
new
Solarium_Result_Select_Facet_Range
(
$counts
,
$before
,
$after
,
$between
);
return
new
Solarium_Result_Select_Facet_Range
(
$counts
,
$before
,
$after
,
$between
,
$start
,
$end
,
$gap
);
}
}
}
\ No newline at end of file
}
library/Solarium/Result/Select/Facet/Range.php
View file @
3fc0b564
...
...
@@ -73,6 +73,27 @@ class Solarium_Result_Select_Facet_Range extends Solarium_Result_Select_Facet_Fi
*/
protected
$_between
;
/**
* The lower bound of the ranges
*
* @var string
*/
protected
$_start
;
/**
* The upper bound of all ranges
*
* @var string
*/
protected
$_end
;
/**
* The gap between each range
*
* @var string
*/
protected
$_gap
;
/**
* Constructor
*
...
...
@@ -82,12 +103,15 @@ class Solarium_Result_Select_Facet_Range extends Solarium_Result_Select_Facet_Fi
* @param int $between
* @return void
*/
public
function
__construct
(
$values
,
$before
,
$after
,
$between
)
public
function
__construct
(
$values
,
$before
,
$after
,
$between
,
$start
,
$end
,
$gap
)
{
$this
->
_values
=
$values
;
$this
->
_before
=
$before
;
$this
->
_after
=
$after
;
$this
->
_between
=
$between
;
$this
->
_start
=
$start
;
$this
->
_end
=
$end
;
$this
->
_gap
=
$gap
;
}
/**
...
...
@@ -129,4 +153,40 @@ class Solarium_Result_Select_Facet_Range extends Solarium_Result_Select_Facet_Fi
return
$this
->
_between
;
}
}
\ No newline at end of file
/**
* Get 'start' value of the ranges
*
* The start value specified in the query facet.
*
* @return string
*/
public
function
getStart
()
{
return
$this
->
_start
;
}
/**
* Get 'end' value of the ranges
*
* The end value specified in the query facet
*
* @return string
*/
public
function
getEnd
()
{
return
$this
->
_end
;
}
/**
* Get 'gap' between the start and end of each range
*
* Get the gap specified in the query facet
*
* @return string
*/
public
function
getGap
()
{
return
$this
->
_gap
;
}
}
tests/Solarium/Result/Select/Facet/RangeTest.php
View file @
3fc0b564
...
...
@@ -37,7 +37,7 @@ class Solarium_Result_Select_Facet_RangeTest extends PHPUnit_Framework_TestCase
*/
protected
$_facet
;
protected
$_values
,
$_before
,
$_after
,
$_between
;
protected
$_values
,
$_before
,
$_after
,
$_between
,
$_start
,
$_end
,
$_gap
;
public
function
setUp
()
{
...
...
@@ -49,8 +49,11 @@ class Solarium_Result_Select_Facet_RangeTest extends PHPUnit_Framework_TestCase
$this
->
_before
=
2
;
$this
->
_after
=
4
;
$this
->
_between
=
3
;
$this
->
_start
=
'10.0'
;
$this
->
_end
=
'40.0'
;
$this
->
_gap
=
'10.0'
;
$this
->
_facet
=
new
Solarium_Result_Select_Facet_Range
(
$this
->
_values
,
$this
->
_before
,
$this
->
_after
,
$this
->
_between
);
$this
->
_facet
=
new
Solarium_Result_Select_Facet_Range
(
$this
->
_values
,
$this
->
_before
,
$this
->
_after
,
$this
->
_between
,
$this
->
_start
,
$this
->
_end
,
$this
->
_gap
);
}
public
function
testGetValues
()
...
...
@@ -89,4 +92,18 @@ class Solarium_Result_Select_Facet_RangeTest extends PHPUnit_Framework_TestCase
$this
->
assertEquals
(
$this
->
_between
,
$this
->
_facet
->
getBetween
());
}
public
function
testGetStart
()
{
$this
->
assertEquals
(
$this
->
_start
,
$this
->
_facet
->
getStart
());
}
public
function
testGetEnd
()
{
$this
->
assertEquals
(
$this
->
_end
,
$this
->
_facet
->
getEnd
());
}
public
function
testGetGap
()
{
$this
->
assertEquals
(
$this
->
_gap
,
$this
->
_facet
->
getGap
());
}
}
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