Skip to content
GitLab
Explore
Sign in
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
2a274e58
Commit
2a274e58
authored
4 years ago
by
Bartek Wrona
Browse files
Options
Downloads
Patches
Plain Diff
Fixed bug related to no last-read case (and processing null block number at further parts of query)
parent
43bba05e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!456
Release candidate v1 24
,
!348
get_number_of_unread_notifications speedup
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hive/db/sql_scripts/notifications_api.sql
+8
-6
8 additions, 6 deletions
hive/db/sql_scripts/notifications_api.sql
with
8 additions
and
6 deletions
hive/db/sql_scripts/notifications_api.sql
+
8
−
6
View file @
2a274e58
...
@@ -24,7 +24,7 @@ $BODY$
...
@@ -24,7 +24,7 @@ $BODY$
DECLARE
DECLARE
__account_id
INT
:
=
0
;
__account_id
INT
:
=
0
;
__last_read_at
TIMESTAMP
;
__last_read_at
TIMESTAMP
;
__last_read_at_block
INT
;
__last_read_at_block
hive_blocks
.
num
%
TYPE
;
__limit_block
hive_blocks
.
num
%
TYPE
=
block_before_head
(
'90 days'
);
__limit_block
hive_blocks
.
num
%
TYPE
=
block_before_head
(
'90 days'
);
BEGIN
BEGIN
__account_id
=
find_account_id
(
_account
,
True
);
__account_id
=
find_account_id
(
_account
,
True
);
...
@@ -33,11 +33,13 @@ BEGIN
...
@@ -33,11 +33,13 @@ BEGIN
FROM
hive_accounts
ha
FROM
hive_accounts
ha
WHERE
ha
.
id
=
__account_id
;
WHERE
ha
.
id
=
__account_id
;
SELECT
hb
.
num
INTO
__last_read_at_block
--- Warning given account can have no last_read_at set, so lets fallback to the block limit to avoid comparison to NULL.
FROM
hive_blocks
hb
SELECT
COALESCE
((
SELECT
hb
.
num
WHERE
hb
.
created_at
<=
__last_read_at
FROM
hive_blocks
hb
ORDER
by
hb
.
created_at
desc
WHERE
hb
.
created_at
<=
__last_read_at
LIMIT
1
;
ORDER
by
hb
.
created_at
desc
LIMIT
1
),
__limit_block
)
INTO
__last_read_at_block
;
RETURN
QUERY
SELECT
RETURN
QUERY
SELECT
__last_read_at
as
lastread_at
,
__last_read_at
as
lastread_at
,
...
...
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