Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hivemind
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
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
hive
hivemind
Commits
3f1bd45d
Commit
3f1bd45d
authored
2 years ago
by
Mateusz Żebrak
Committed by
Bartek Wrona
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Create get_head_state function
parent
4ef85ed9
No related branches found
No related tags found
2 merge requests
!584
Changes to be delivered to master as 1.27 release
,
!558
Merge develop-haf with current develop
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hive/db/sql_scripts/utility_functions.sql
+36
-0
36 additions, 0 deletions
hive/db/sql_scripts/utility_functions.sql
with
36 additions
and
0 deletions
hive/db/sql_scripts/utility_functions.sql
+
36
−
0
View file @
3f1bd45d
...
@@ -214,3 +214,39 @@ BEGIN
...
@@ -214,3 +214,39 @@ BEGIN
END
END
$
function
$
$
function
$
;
;
DROP
TYPE
IF
EXISTS
hivemind_app
.
head_state
CASCADE
;
CREATE
TYPE
hivemind_app
.
head_state
AS
(
num
int
,
created_at
timestamp
,
age
int
);
DROP
FUNCTION
IF
EXISTS
hivemind_app
.
get_head_state
();
CREATE
OR
REPLACE
FUNCTION
hivemind_app
.
get_head_state
()
RETURNS
SETOF
hivemind_app
.
head_state
LANGUAGE
'plpgsql'
AS
$$
DECLARE
__num
int
;
__created_at
timestamp
:
=
'1970-01-01 00:00:00'
::
timestamp
;
__record
hivemind_app
.
head_state
;
BEGIN
SELECT
current_block_num
INTO
__num
FROM
hive
.
hivemind_app_context_data_view
;
IF
__num
>
0
THEN
SELECT
created_at
INTO
__created_at
FROM
hive
.
hivemind_app_blocks_view
WHERE
num
=
__num
;
ELSE
-- MIGHT BE NULL
__num
=
0
;
END
IF
;
__record
.
num
=
__num
;
__record
.
created_at
=
__created_at
;
__record
.
age
=
extract
(
epoch
from
__created_at
);
RETURN
NEXT
__record
;
END
$$
;
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