Skip to content

Commit

Permalink
Fix project counter
Browse files Browse the repository at this point in the history
  • Loading branch information
loleg committed Mar 27, 2023
1 parent 0c90ac7 commit 6d35984
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
16 changes: 7 additions & 9 deletions dribdat/user/models.py
Expand Up @@ -171,17 +171,15 @@ def joined_projects(self, with_challenges=True, limit=-1):
"""Retrieve all projects user has joined."""
activities = Activity.query.filter_by(
user_id=self.id, name='star'
).order_by(Activity.timestamp.desc())
if limit < 0:
activities = activities.all()
else:
activities = activities.limit(limit * 2)
).order_by(Activity.timestamp.desc()).all()
projects = []
project_ids = []
for a in activities:
if a.project not in projects and not a.project.is_hidden:
if with_challenges or a.project.progress != 0:
if len(projects) < limit:
projects.append(a.project)
if limit > 0 and len(projects) >= limit: continue
if a.project_id not in project_ids and not a.project.is_hidden:
if with_challenges or a.project.progress > 0:
projects.append(a.project)
project_ids.append(a.project_id)
return projects

def posted_challenges(self):
Expand Down
1 change: 1 addition & 0 deletions tests/test_import.py
Expand Up @@ -69,6 +69,7 @@ def test_user_schema(self, project, testapp):
# Now we are a member of one project
schema = get_schema_for_user_projects(user, hosturl)
assert len(schema) == 1
assert 'message' not in schema
assert len(schema[0]["workPerformed"]) == 1

# Create another project
Expand Down

0 comments on commit 6d35984

Please sign in to comment.