Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
holi-okuna
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
app
holi-okuna
Commits
aa36a3a6
Unverified
Commit
aa36a3a6
authored
4 years ago
by
Joel Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
add praocess post links mgt command
parent
aaa17cd9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openbook_hashtags/management/commands/process_post_links.py
+32
-0
32 additions, 0 deletions
openbook_hashtags/management/commands/process_post_links.py
with
32 additions
and
0 deletions
openbook_hashtags/management/commands/process_post_links.py
0 → 100644
+
32
−
0
View file @
aa36a3a6
from
django.core.management.base
import
BaseCommand
import
logging
from
django.db
import
transaction
from
openbook_common.utils.model_loaders
import
get_post_model
from
openbook_posts.jobs
import
_chunked_queryset_iterator
logger
=
logging
.
getLogger
(
__name__
)
class
Command
(
BaseCommand
):
help
=
'
Process the Posts
\'
s links
'
def
handle
(
self
,
*
args
,
**
options
):
Post
=
get_post_model
()
posts_to_process
=
Post
.
objects
.
filter
(
links__isnull
=
True
,
text__isnull
=
False
,
text__icontains
=
'
http
'
).
only
(
'
id
'
,
'
text
'
).
all
()
migrated_posts
=
0
for
post
in
_chunked_queryset_iterator
(
posts_to_process
,
100
):
try
:
post
.
_process_post_links
()
except
Exception
as
e
:
logger
.
info
(
'
Error processing with error %s
'
%
str
(
e
))
logger
.
info
(
'
Processed links for post with id:
'
+
str
(
post
.
pk
))
migrated_posts
=
migrated_posts
+
1
logger
.
info
(
'
Processed %d posts for links
'
%
migrated_posts
)
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