Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
shadowban-eu-backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
shadowban-eu-backend
Commits
dab877d9
Commit
dab877d9
authored
Feb 18, 2020
by
Raphael Beer
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add: return last result from DB for @wikileaks; unless watch request
parent
ad845e15
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletion
+7
-1
backend.py
backend.py
+3
-0
db.py
db.py
+4
-1
No files found.
backend.py
View file @
dab877d9
...
@@ -509,6 +509,9 @@ async def unlocked(request):
...
@@ -509,6 +509,9 @@ async def unlocked(request):
async
def
api
(
request
):
async
def
api
(
request
):
global
test_index
global
test_index
screen_name
=
request
.
match_info
[
'screen_name'
]
screen_name
=
request
.
match_info
[
'screen_name'
]
if
screen_name
==
"wikileaks"
and
request
.
query_string
!=
"watch"
:
db_result
=
db
.
get_result_by_screen_name
(
"wikileaks"
)
return
web
.
json_response
(
db_result
,
headers
=
{
"Access-Control-Allow-Origin"
:
args
.
cors_allow
})
session
=
guest_sessions
[
test_index
%
len
(
guest_sessions
)]
session
=
guest_sessions
[
test_index
%
len
(
guest_sessions
)]
test_index
+=
1
test_index
+=
1
result
=
await
session
.
test
(
screen_name
)
result
=
await
session
.
test
(
screen_name
)
...
...
db.py
View file @
dab877d9
import
copy
import
copy
import
traceback
import
traceback
import
sys
import
sys
from
pymongo
import
MongoClient
,
errors
as
MongoErrors
from
pymongo
import
MongoClient
,
errors
as
MongoErrors
,
DESCENDING
class
Database
:
class
Database
:
def
__init__
(
self
,
host
=
None
,
port
=
27017
,
db
=
'tester'
):
def
__init__
(
self
,
host
=
None
,
port
=
27017
,
db
=
'tester'
):
...
@@ -38,6 +38,9 @@ class Database:
...
@@ -38,6 +38,9 @@ class Database:
def
write_rate_limit
(
self
,
data
):
def
write_rate_limit
(
self
,
data
):
self
.
rate_limits
.
insert_one
(
data
)
self
.
rate_limits
.
insert_one
(
data
)
def
get_result_by_screen_name
(
self
,
screen_name
):
return
self
.
results
.
find_one
({
"profile.screen_name"
:
screen_name
},
sort
=
[(
"_id"
,
DESCENDING
)],
projection
=
{
"_id"
:
False
})
def
connect
(
host
=
None
,
port
=
27017
,
db
=
'tester'
):
def
connect
(
host
=
None
,
port
=
27017
,
db
=
'tester'
):
if
host
is
None
:
if
host
is
None
:
raise
ValueError
(
'[mongoDB] Database constructor needs a `host`name or ip!'
)
raise
ValueError
(
'[mongoDB] Database constructor needs a `host`name or ip!'
)
...
...
nanahira
@nanahira
mentioned in commit
8f91a6a8
·
Jan 24, 2022
mentioned in commit
8f91a6a8
mentioned in commit 8f91a6a8a932bfa7c95aa049142fdd6b71ac1e89
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment