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
eb26a9e9
Commit
eb26a9e9
authored
4 years ago
by
Dariusz Kędzierski
Browse files
Options
Downloads
Patches
Plain Diff
Escape characters in tags
parent
b7d73ab9
No related branches found
No related tags found
5 merge requests
!456
Release candidate v1 24
,
!230
Setup monitoring with pghero
,
!135
Enable postgres monitoring on CI server
,
!16
Dk issue 3 concurrent block query rebase
,
!15
Dk issue 3 concurrent block query
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
hive/indexer/post_data_cache.py
+1
-10
1 addition, 10 deletions
hive/indexer/post_data_cache.py
hive/indexer/tags.py
+4
-2
4 additions, 2 deletions
hive/indexer/tags.py
hive/utils/normalize.py
+10
-0
10 additions, 0 deletions
hive/utils/normalize.py
with
15 additions
and
12 deletions
hive/indexer/post_data_cache.py
+
1
−
10
View file @
eb26a9e9
import
logging
from
hive.utils.normalize
import
escape_characters
from
hive.db.adapter
import
Db
log
=
logging
.
getLogger
(
__name__
)
DB
=
Db
.
instance
()
def
escape_characters
(
text
):
"""
Escape special charactes
"""
ret
=
str
(
text
)
ret
=
ret
.
replace
(
"
\\
"
,
"
\\\\
"
)
ret
=
ret
.
replace
(
"'"
,
"''"
)
ret
=
ret
.
replace
(
"
%
"
,
'
%%
'
)
ret
=
ret
.
replace
(
"
_
"
,
"
\\
_
"
)
ret
=
ret
.
replace
(
"
:
"
,
"
\\
:
"
)
return
ret
class
PostDataCache
(
object
):
"""
Procides cache for DB operations on post data table in order to speed up initial sync
"""
_data
=
{}
...
...
This diff is collapsed.
Click to expand it.
hive/indexer/tags.py
+
4
−
2
View file @
eb26a9e9
...
...
@@ -4,6 +4,8 @@ from hive.db.adapter import Db
log
=
logging
.
getLogger
(
__name__
)
DB
=
Db
.
instance
()
from
hive.utils.normalize
import
escape_characters
class
Tags
(
object
):
"""
Tags cache
"""
_tags
=
[]
...
...
@@ -24,7 +26,7 @@ class Tags(object):
"""
values
=
[]
for
tag
in
cls
.
_tags
:
values
.
append
(
"
(
'
{}
'
)
"
.
format
(
tag
[
1
]))
values
.
append
(
"
(
'
{}
'
)
"
.
format
(
escape_characters
(
tag
[
1
]))
)
sql
+=
"
,
"
.
join
(
values
)
sql
+=
"
ON CONFLICT DO NOTHING;
"
...
...
@@ -35,7 +37,7 @@ class Tags(object):
"""
values
=
[]
for
tag
in
cls
.
_tags
:
values
.
append
(
"
({}, (SELECT id FROM hive_tag_data WHERE tag=
'
{}
'
))
"
.
format
(
tag
[
0
],
tag
[
1
]))
values
.
append
(
"
({}, (SELECT id FROM hive_tag_data WHERE tag=
'
{}
'
))
"
.
format
(
tag
[
0
],
escape_characters
(
tag
[
1
]))
)
sql
+=
"
,
"
.
join
(
values
)
sql
+=
"
ON CONFLICT DO NOTHING
"
DB
.
query
(
sql
)
...
...
This diff is collapsed.
Click to expand it.
hive/utils/normalize.py
+
10
−
0
View file @
eb26a9e9
...
...
@@ -13,6 +13,16 @@ NAI_MAP = {
'
@@000000037
'
:
'
VESTS
'
,
}
def
escape_characters
(
text
):
"""
Escape special charactes
"""
ret
=
str
(
text
)
ret
=
ret
.
replace
(
"
\\
"
,
"
\\\\
"
)
ret
=
ret
.
replace
(
"'"
,
"''"
)
ret
=
ret
.
replace
(
"
%
"
,
'
%%
'
)
ret
=
ret
.
replace
(
"
_
"
,
"
\\
_
"
)
ret
=
ret
.
replace
(
"
:
"
,
"
\\
:
"
)
return
ret
def
vests_amount
(
value
):
"""
Returns a decimal amount, asserting units are VESTS
"""
return
parse_amount
(
value
,
'
VESTS
'
)
...
...
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