SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
119
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
SciPost
SciPost
Commits
dfcb678d
Commit
dfcb678d
authored
2 years ago
by
Jean-Sébastien Caux
Browse files
Options
Downloads
Patches
Plain Diff
Improve posts counting
parent
c80dba09
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
scipost_django/forums/models.py
+11
-9
11 additions, 9 deletions
scipost_django/forums/models.py
with
11 additions
and
9 deletions
scipost_django/forums/models.py
+
11
−
9
View file @
dfcb678d
...
...
@@ -101,12 +101,13 @@ class Forum(models.Model):
@property
def
nr_posts
(
self
):
"""
Recursively counts the number of posts in this Forum.
"""
"""
Recursively counts the number of
motions and
posts in this Forum.
"""
nr
=
0
for
post
in
self
.
posts
.
all
():
nr
+=
post
.
nr_followups
if
self
.
posts
.
all
():
nr
+=
self
.
posts
.
all
().
count
()
posts
=
self
.
posts
.
all
()
# gathers all Posts (including those with a Motion)
if
posts
:
nr
+=
posts
.
count
()
for
post
in
self
.
posts
.
all
():
nr
+=
post
.
nr_followups
return
nr
def
update_cf_nr_posts
(
self
):
...
...
@@ -317,10 +318,11 @@ class Post(models.Model):
@property
def
nr_followups
(
self
):
nr
=
0
for
followup
in
self
.
followup_posts
.
all
():
nr
+=
followup
.
nr_followups
if
self
.
followup_posts
:
nr
+=
self
.
followup_posts
.
all
().
count
()
followups
=
self
.
get_followups
()
if
followups
:
nr
+=
followups
.
count
()
for
followup
in
followups
.
all
():
nr
+=
followup
.
nr_followups
return
nr
def
update_cf_nr_followups
(
self
):
...
...
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