Skip to content

Commit

Permalink
simplify syncmodifyapi project querying (#1264)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkonie committed Aug 25, 2023
1 parent f9dfadd commit 4d7049d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Changed
- Move ``setup_ip_allowing()`` to ``IPAllowMixin`` (#1237)
- Improve ``syncmodifyapi`` project logging (#1228)
- Do not exit ``syncmodifyapi`` on failure (#1229)
- Simplify ``syncmodifyapi`` project querying (#1264)
- **Timeline**
- Handle app plugin exceptions in ``get_object_link()`` (#1232)

Expand Down
22 changes: 2 additions & 20 deletions projectroles/management/commands/syncmodifyapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,6 @@
class Command(ProjectModifyPluginViewMixin, BaseCommand):
help = 'Synchronizes existing projects using the project modify API'

def _get_projects(self, project, project_list):
"""
Retrieve projects recursively in inheritance order.
:param project: Current project
:param project_list: List of Project objects
"""
project_list.append(project)
logger.debug('Added: {}'.format(project.full_title))
for c in Project.objects.filter(parent=project):
self._get_projects(c, project_list)
return project_list

def add_arguments(self, parser):
parser.add_argument(
'-p',
Expand All @@ -61,14 +48,9 @@ def handle(self, *args, **options):
project_list = [project]
else:
logger.info('Synchronizing all projects..')
project_list = []
top_cats = Project.objects.filter(
type=PROJECT_TYPE_CATEGORY, parent=None
)
for c in top_cats:
self._get_projects(c, project_list)
project_list = Project.objects.all().order_by('full_title')
logger.debug(
'Found {} projects and categories'.format(len(project_list))
'Found {} projects and categories'.format(project_list.count())
)
sync_count = 0
err_count = 0
Expand Down

0 comments on commit 4d7049d

Please sign in to comment.