Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
network
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Code
Merge requests
9
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
funkwhale
network
Commits
27012108
Unverified
Commit
27012108
authored
2 years ago
by
jooola
Browse files
Options
Downloads
Patches
Plain Diff
style: format code using black (pre-commit)
parent
4314e3ed
No related branches found
No related tags found
1 merge request
!61
chore: update pre-commit hooks
Pipeline
#28582
passed with warnings with stages
in 3 minutes and 18 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
funkwhale_network/cli.py
+0
-1
0 additions, 1 deletion
funkwhale_network/cli.py
funkwhale_network/db.py
+15
-15
15 additions, 15 deletions
funkwhale_network/db.py
funkwhale_network/output.py
+0
-1
0 additions, 1 deletion
funkwhale_network/output.py
tests/test_db.py
+0
-1
0 additions, 1 deletion
tests/test_db.py
with
15 additions
and
18 deletions
funkwhale_network/cli.py
+
0
−
1
View file @
27012108
...
...
@@ -153,7 +153,6 @@ async def crawl(domain, use_public, detail, passes, sort):
aggregate
=
aggregate_crawl_results
(
results
[
"
results
"
])
if
detail
!=
NOOP
:
click
.
echo
(
""
)
click
.
echo
(
"
Info per domain
"
)
click
.
echo
(
"
===============
"
)
...
...
This diff is collapsed.
Click to expand it.
funkwhale_network/db.py
+
15
−
15
View file @
27012108
...
...
@@ -36,7 +36,7 @@ class DB:
yield
self
.
pool
.
cursor
()
async
def
create_domains_table
(
self
):
with
(
await
self
.
pool
.
cursor
()
)
as
cursor
:
with
await
self
.
pool
.
cursor
()
as
cursor
:
await
cursor
.
execute
(
"""
CREATE TABLE IF NOT EXISTS domains (
...
...
@@ -77,7 +77,7 @@ class DB:
ALTER TABLE checks ADD COLUMN IF NOT EXISTS usage_downloads_total INTEGER NULL;
SELECT create_hypertable(
'
checks
'
,
'
time
'
, if_not_exists => TRUE);
"""
with
(
await
self
.
pool
.
cursor
()
)
as
cursor
:
with
await
self
.
pool
.
cursor
()
as
cursor
:
await
cursor
.
execute
(
sql
)
cursor
.
close
()
...
...
@@ -86,7 +86,7 @@ class DB:
await
create_handler
()
async
def
clear
(
self
):
with
(
await
self
.
pool
.
cursor
()
)
as
cursor
:
with
await
self
.
pool
.
cursor
()
as
cursor
:
for
table
,
_
in
self
.
TABLES
:
await
cursor
.
execute
(
f
"
DROP TABLE IF EXISTS
{
table
}
CASCADE
"
)
...
...
@@ -98,8 +98,8 @@ class DB:
WHERE private = %s AND domains.blocked = false
ORDER BY domain, time DESC
"""
with
(
await
self
.
pool
.
cursor
(
cursor_factory
=
psycopg2
.
extras
.
RealDictCursor
)
with
await
self
.
pool
.
cursor
(
cursor_factory
=
psycopg2
.
extras
.
RealDictCursor
)
as
cursor
:
await
cursor
.
execute
(
sql
,
[
False
])
return
list
(
await
cursor
.
fetchall
())
...
...
@@ -165,16 +165,16 @@ class DB:
return
base_query
.
format
(
where_clause
=
""
),
[]
async
def
get_all_domains
(
self
):
with
(
await
self
.
pool
.
cursor
(
cursor_factory
=
psycopg2
.
extras
.
RealDictCursor
)
with
await
self
.
pool
.
cursor
(
cursor_factory
=
psycopg2
.
extras
.
RealDictCursor
)
as
cursor
:
await
cursor
.
execute
(
"
SELECT name FROM domains
"
)
domains
=
list
(
await
cursor
.
fetchall
())
return
domains
async
def
get_domains
(
self
,
**
kwargs
):
with
(
await
self
.
pool
.
cursor
(
cursor_factory
=
psycopg2
.
extras
.
RealDictCursor
)
with
await
self
.
pool
.
cursor
(
cursor_factory
=
psycopg2
.
extras
.
RealDictCursor
)
as
cursor
:
filters
=
kwargs
.
copy
()
filters
.
setdefault
(
"
private
"
,
False
)
...
...
@@ -209,15 +209,15 @@ class DB:
return
True
async
def
get_domain
(
self
,
name
):
with
(
await
self
.
pool
.
cursor
(
cursor_factory
=
psycopg2
.
extras
.
RealDictCursor
)
with
await
self
.
pool
.
cursor
(
cursor_factory
=
psycopg2
.
extras
.
RealDictCursor
)
as
cursor
:
await
cursor
.
execute
(
"
SELECT * FROM domains WHERE name = %s
"
,
(
name
,))
return
list
(
await
cursor
.
fetchall
())[
0
]
async
def
save_check
(
self
,
data
):
with
(
await
self
.
pool
.
cursor
(
cursor_factory
=
psycopg2
.
extras
.
RealDictCursor
)
with
await
self
.
pool
.
cursor
(
cursor_factory
=
psycopg2
.
extras
.
RealDictCursor
)
as
cursor
:
node_name
=
data
.
pop
(
"
node_name
"
,
None
)
fields
,
values
=
[],
[]
...
...
@@ -245,8 +245,8 @@ class DB:
return
check
async
def
create_domain
(
self
,
data
):
with
(
await
self
.
pool
.
cursor
(
cursor_factory
=
psycopg2
.
extras
.
RealDictCursor
)
with
await
self
.
pool
.
cursor
(
cursor_factory
=
psycopg2
.
extras
.
RealDictCursor
)
as
cursor
:
sql
=
"
INSERT INTO domains (name) VALUES (%s) ON CONFLICT DO NOTHING RETURNING *
"
await
cursor
.
execute
(
sql
,
[
data
[
"
name
"
]])
...
...
This diff is collapsed.
Click to expand it.
funkwhale_network/output.py
+
0
−
1
View file @
27012108
...
...
@@ -51,7 +51,6 @@ def get_value(obj, config, truncate=30):
def
table
(
objects
,
fields
,
type
,
headers
=
True
,
format
=
"
simple
"
,
sort
=
None
):
configs
=
{}
if
sort
:
...
...
This diff is collapsed.
Click to expand it.
tests/test_db.py
+
0
−
1
View file @
27012108
...
...
@@ -14,7 +14,6 @@ async def test_create_domain_ignore_duplicate(populated_db):
async
def
test_db_create
():
async
with
DB
()
as
db
:
try
:
await
db
.
create
()
...
...
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