Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
framadate
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nounous
framadate
Commits
49a5350f
Commit
49a5350f
authored
9 years ago
by
Olivier PEREZ
Browse files
Options
Downloads
Patches
Plain Diff
Fix #83 Stop sorting moments at new slot insertion
parent
c6c95466
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/classes/Framadate/Services/AdminPollService.php
+4
-17
4 additions, 17 deletions
app/classes/Framadate/Services/AdminPollService.php
with
4 additions
and
17 deletions
app/classes/Framadate/Services/AdminPollService.php
+
4
−
17
View file @
49a5350f
...
...
@@ -202,7 +202,7 @@ class AdminPollService {
$this
->
logService
->
log
(
'ADD_SLOT'
,
'id:'
.
$poll_id
.
', datetime:'
.
$datetime
.
', moment:'
.
$new_moment
);
$slots
=
$this
->
slotRepository
->
listByPollId
(
$poll_id
);
$result
=
$this
->
findInsertPosition
(
$slots
,
$datetime
,
$new_moment
);
$result
=
$this
->
findInsertPosition
(
$slots
,
$datetime
);
// Begin transaction
$this
->
connect
->
beginTransaction
();
...
...
@@ -221,7 +221,6 @@ class AdminPollService {
// Update found slot
$moments
[]
=
$new_moment
;
sort
(
$moments
);
$this
->
slotRepository
->
update
(
$poll_id
,
$datetime
,
implode
(
','
,
$moments
));
}
else
{
...
...
@@ -284,10 +283,9 @@ class AdminPollService {
*
* @param $slots array All the slots of the poll
* @param $datetime int The datetime of the new slot
* @param $moment string The moment's name
* @return null|\stdClass An object like this one: {insert:X, slot:Y} where Y can be null.
*/
private
function
findInsertPosition
(
$slots
,
$datetime
,
$moment
)
{
private
function
findInsertPosition
(
$slots
,
$datetime
)
{
$result
=
new
\stdClass
();
$result
->
slot
=
null
;
$result
->
insert
=
-
1
;
...
...
@@ -299,21 +297,10 @@ class AdminPollService {
$moments
=
explode
(
','
,
$slot
->
moments
);
if
(
$datetime
==
$rowDatetime
)
{
$result
->
slot
=
$slot
;
foreach
(
$moments
as
$rowMoment
)
{
$strcmp
=
strcmp
(
$moment
,
$rowMoment
);
if
(
$strcmp
<
0
)
{
// Here we have to insert at First place or middle of the slot
break
(
2
);
}
elseif
(
$strcmp
==
0
)
{
// Here we dont have to insert at all
return
null
;
}
$i
++
;
}
$i
+=
count
(
$moments
);
// Here we have to insert at the end of a slot
$result
->
slot
=
$slot
;
$result
->
insert
=
$i
;
break
;
}
elseif
(
$datetime
<
$rowDatetime
)
{
...
...
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