Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Maják
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
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
TO
Maják
Commits
82b1647f
Commit
82b1647f
authored
2 years ago
by
OndraRehounek
Browse files
Options
Downloads
Patches
Plain Diff
main: exclude retweets
parent
e1ef975d
No related branches found
No related tags found
2 merge requests
!609
Release
,
!608
Small tuning and fixes of pirati.cz (main) module
Pipeline
#9631
passed
2 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
twitter_utils/services.py
+15
-4
15 additions, 4 deletions
twitter_utils/services.py
with
15 additions
and
4 deletions
twitter_utils/services.py
+
15
−
4
View file @
82b1647f
...
...
@@ -6,7 +6,7 @@ from django.utils import timezone
from
tweepy
import
Client
from
tweepy.errors
import
BadRequest
from
main.models
import
MainHomePage
from
main.models
import
MainHomePage
,
MainPersonPage
from
.models
import
Tweet
...
...
@@ -48,6 +48,7 @@ class TweetDownloadService:
"""
tweets_response
=
self
.
client
.
get_users_tweets
(
user_id
,
exclude
=
[
"
retweets
"
],
expansions
=
[
"
author_id
"
,
"
entities.mentions.username
"
],
max_results
=
100
,
start_time
=
timezone
.
now
()
-
timedelta
(
days
=
self
.
days_back
),
...
...
@@ -59,15 +60,25 @@ class TweetDownloadService:
def
get_user_list_data
(
self
)
->
list
[
"
User
"
]:
twitter_usernames_block
=
MainHomePage
.
objects
.
first
().
twitter_usernames
person_username_list
=
(
MainPersonPage
.
objects
.
filter
(
twitter_username__isnull
=
False
)
.
values_list
(
"
twitter_username
"
,
flat
=
True
)
.
distinct
()
)
homepage_username_list
=
[
username_data
[
"
value
"
]
for
username_data
in
twitter_usernames_block
.
raw_data
]
username_list
=
[
*
person_username_list
,
*
homepage_username_list
]
user_data_list
=
[]
for
username
_data
in
twitter_usernames_block
.
raw_data
:
for
username
in
username_list
:
try
:
user_data_list
.
append
(
self
.
get_user_response
(
username
_data
[
"
value
"
]
))
user_data_list
.
append
(
self
.
get_user_response
(
username
))
except
BadRequest
:
logger
.
error
(
"
Cannot download tweets for the username
"
,
extra
=
{
"
username
"
:
username
_data
[
"
value
"
]
},
extra
=
{
"
username
"
:
username
},
)
return
user_data_list
...
...
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