Repository: regro/regolith

Issue:
BUG: l_projecta --list_by_lead doesn't play with other filters
Current behavior:
lots of nice filtering keys are available, OR listing by lead is available, but they don't play together.

Desired behavior:
set filters, such as ``-f status started --list_by_lead`` and it will return current (not finished) prums listed by lead

Discussion:

Patch:
diff --git a/news/group_by_lead_expansion.rst b/news/group_by_lead_expansion.rst
new file mode 100644
index 00000000..c63b6de1
--- /dev/null
+++ b/news/group_by_lead_expansion.rst
@@ -0,0 +1,12 @@
+**Added:** None
+
+**Changed:**
+    * group_by_lead flag in l_projecta can now be used with other flags
+
+**Deprecated:** None
+
+**Removed:** None
+
+**Fixed:** None
+
+**Security:** None
\ No newline at end of file
diff --git a/regolith/helpers/l_projectahelper.py b/regolith/helpers/l_projectahelper.py
index 17b41f61..5a195041 100644
--- a/regolith/helpers/l_projectahelper.py
+++ b/regolith/helpers/l_projectahelper.py
@@ -121,12 +121,6 @@ class ProjectaListerHelper(SoutHelperBase):
         if rc.lead and rc.person:
             raise RuntimeError(f"please specify either lead or person, not both")
         for projectum in self.gtx["projecta"]:
-            if rc.grp_by_lead:
-                if projectum.get('lead') not in grouped_projecta:
-                    grouped_projecta[projectum.get('lead')] = [projectum.get('_id')]
-                else:
-                    grouped_projecta[projectum.get('lead')].append(projectum.get('_id'))
-                continue
             if isinstance(projectum.get('group_members'), str):
                 projectum['group_members'] = [projectum.get('group_members')]
             if rc.lead and projectum.get('lead') != rc.lead:
@@ -159,7 +153,7 @@ class ProjectaListerHelper(SoutHelperBase):
                 if low_range <= end_date <= high_range:
                     end_projecta.append(projectum)
                 continue
-            projecta.append(projectum["_id"])
+            projecta.append(projectum)
 
         if rc.ended:
             for p in end_projecta:
@@ -173,11 +167,18 @@ class ProjectaListerHelper(SoutHelperBase):
                                                                                           p.get("lead"), members,
                                                                                           collaborators))
         if rc.grp_by_lead:
+            for p in projecta:
+                if p.get('lead') not in grouped_projecta:
+                    grouped_projecta[p.get('lead')] = [p.get('_id')]
+                else:
+                    grouped_projecta[p.get('lead')].append(p.get('_id'))
             for key, values in grouped_projecta.items():
                 print(f"{key}:")
                 for v in values:
                     print(f"    {v}")
-        projecta.sort()
+            return
+
+        projecta.sort(key=lambda prum: prum.get("_id"))
         for i in projecta:
-            print(i)
+            print(i.get("_id"))
         return


Test patch:
diff --git a/tests/test_helpers.py b/tests/test_helpers.py
index 64308284..bb9343f1 100644
--- a/tests/test_helpers.py
+++ b/tests/test_helpers.py
@@ -46,6 +46,9 @@ helper_map = [
     (["helper", "l_projecta", "--grp_by_lead"],
      "lyang:\n    20ly_newprojectum\nascopatz:\n    20sb_firstprojectum\n"
      ),
+    (["helper", "l_projecta", "--grp_by_lead", "-l", "ascopatz"],
+     "ascopatz:\n    20sb_firstprojectum\n"
+     ),
     (["helper", "l_projecta", "--ended", "--date", "2020-06-02"],
      "20sb_firstprojectum    My first projectum\n    Lead: ascopatz    Members: ascopatz    Collaborators: aeinstein, pdirac\n"
      ),
@@ -70,7 +73,7 @@ helper_map = [
      ""
      ),
     (["helper", "u_milestone", "20sb_firstprojectum", "--index", "4",
-      "--status", "proposed", "--type", "meeting","--due_date", "2020-05-30"],
+      "--status", "proposed", "--type", "meeting", "--due_date", "2020-05-30"],
      "20sb_firstprojectum has been updated in projecta\n"
      ),
     (["helper", "u_milestone", "20sb_firstprojectum", "--verbose"],