Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MaarchCourrier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maarch
MaarchCourrier
Commits
36e9160e
Commit
36e9160e
authored
2 years ago
by
Jean-Laurent DUZANT
Browse files
Options
Downloads
Patches
Plain Diff
FIX #19580 TIME 1:20 create and update chrono value in parameters from increase_chrono
parent
2bd70e67
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
sql/structure.sql
+7
-2
7 additions, 2 deletions
sql/structure.sql
src/app/resource/models/ChronoModel.php
+9
-6
9 additions, 6 deletions
src/app/resource/models/ChronoModel.php
src/core/models/DatabaseModel.php
+3
-3
3 additions, 3 deletions
src/core/models/DatabaseModel.php
with
19 additions
and
11 deletions
sql/structure.sql
+
7
−
2
View file @
36e9160e
...
...
@@ -1559,13 +1559,18 @@ CREATE TABLE address_sectors
)
WITH
(
OIDS
=
FALSE
);
CREATE
OR
REPLACE
FUNCTION
public
.
increase_chrono
(
chrono_id_seq
text
)
returns
table
(
chrono_id
bigint
)
as
$$
CREATE
OR
REPLACE
FUNCTION
public
.
increase_chrono
(
chrono_id_seq
text
,
chrono_id_name
text
)
returns
table
(
chrono_id
bigint
)
as
$$
DECLARE
retval
bigint
;
BEGIN
IF
NOT
EXISTS
(
SELECT
0
FROM
pg_class
where
relname
=
chrono_id_seq
)
THEN
EXECUTE
'CREATE SEQUENCE '
||
chrono_id_seq
||
' INCREMENT 1 MINVALUE 100 MAXVALUE 9223372036854775807 START 100 CACHE 1;'
;
END
IF
;
RETURN
QUERY
EXECUTE
'SELECT nextval($1)'
USING
chrono_id_seq
;
IF
NOT
EXISTS
(
SELECT
0
FROM
parameters
where
id
=
chrono_id_name
)
THEN
EXECUTE
'INSERT INTO parameters (id, param_value_int) VALUES (
''
'
||
chrono_id_name
||
'
''
, 1)'
;
END
IF
;
SELECT
nextval
(
chrono_id_seq
)
INTO
retval
;
UPDATE
parameters
set
param_value_int
=
retval
WHERE
id
=
chrono_id_name
;
RETURN
QUERY
SELECT
retval
;
END
;
$$
LANGUAGE
plpgsql
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/app/resource/models/ChronoModel.php
+
9
−
6
View file @
36e9160e
...
...
@@ -87,8 +87,9 @@ class ChronoModel
*/
public
static
function
getChronoGlobal
()
{
$chronoId
=
'chrono_global_'
.
date
(
'Y'
)
.
"_seq"
;
$chrono
=
DatabaseModel
::
createOrIncreaseChrono
([
'chronoId'
=>
$chronoId
]);
$chronoIdName
=
'chrono_global_'
.
date
(
'Y'
);
$chronoSeqName
=
$chronoIdName
.
"_seq"
;
$chrono
=
DatabaseModel
::
createOrIncreaseChrono
([
'chronoIdName'
=>
$chronoIdName
,
'chronoSeqName'
=>
$chronoSeqName
]);
return
$chrono
;
}
...
...
@@ -97,15 +98,17 @@ class ChronoModel
*/
public
static
function
getChronoEntity
(
$entityId
)
{
$chronoId
=
"chrono_
{
$entityId
}
_"
.
date
(
'Y'
)
.
"_seq"
;
$chrono
=
DatabaseModel
::
createOrIncreaseChrono
([
'chronoId'
=>
$chronoId
]);
$chronoIdName
=
"chrono_
{
$entityId
}
_"
.
date
(
'Y'
);
$chronoSeqName
=
$chronoIdName
.
"_seq"
;
$chrono
=
DatabaseModel
::
createOrIncreaseChrono
([
'chronoIdName'
=>
$chronoIdName
,
'chronoSeqName'
=>
$chronoSeqName
]);
return
$entityId
.
"/"
.
$chrono
;
}
public
static
function
getChronoCategory
(
$categoryId
)
{
$chronoId
=
"chrono_
{
$categoryId
}
_"
.
date
(
'Y'
)
.
"_seq"
;
$chrono
=
DatabaseModel
::
createOrIncreaseChrono
([
'chronoId'
=>
$chronoId
]);
$chronoIdName
=
"chrono_
{
$categoryId
}
_"
.
date
(
'Y'
);
$chronoSeqName
=
$chronoIdName
.
"_seq"
;
$chrono
=
DatabaseModel
::
createOrIncreaseChrono
([
'chronoIdName'
=>
$chronoIdName
,
'chronoSeqName'
=>
$chronoSeqName
]);
return
"/"
.
$chrono
;
}
...
...
This diff is collapsed.
Click to expand it.
src/core/models/DatabaseModel.php
+
3
−
3
View file @
36e9160e
...
...
@@ -25,10 +25,10 @@ class DatabaseModel
*/
public
static
function
createOrIncreaseChrono
(
array
$args
)
{
ValidatorModel
::
notEmpty
(
$args
,
[
'chronoId'
]);
ValidatorModel
::
stringType
(
$args
,
[
'chronoId'
]);
ValidatorModel
::
notEmpty
(
$args
,
[
'chronoId
Name'
,
'chronoSeqName
'
]);
ValidatorModel
::
stringType
(
$args
,
[
'chronoId
Name'
,
'chronoSeqName
'
]);
$query
=
"SELECT increase_chrono('
{
$args
[
'chrono
Id
'
]
}
')"
;
$query
=
"SELECT increase_chrono('
{
$args
[
'chrono
SeqName'
]
}
' ,'
{
$args
[
'chronoIdName
'
]
}
')"
;
$db
=
new
DatabasePDO
();
$stmt
=
$db
->
query
(
$query
);
...
...
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