This is an automated email from the ASF dual-hosted git repository.

tn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-release.git


The following commit(s) were added to refs/heads/main by this push:
     new ed6a2e7  add committee views, rework update mechanism
ed6a2e7 is described below

commit ed6a2e7fd19df176b51e7d2c060d2857a128b08e
Author: Thomas Neidhart <[email protected]>
AuthorDate: Fri Mar 21 10:42:19 2025 +0100

    add committee views, rework update mechanism
---
 atr/blueprints/admin/admin.py                      | 104 +++++++++++++--------
 atr/datasources/apache.py                          |   4 +-
 atr/db/__init__.py                                 |   3 +
 atr/db/models.py                                   |   4 +-
 atr/routes/committees.py                           |  43 +++++++++
 atr/server.py                                      |   2 +
 ...ect-directory.html => committee-directory.html} |  34 ++-----
 .../{project-view.html => committee-view.html}     |  42 +++++----
 atr/templates/includes/sidebar.html                |   5 +
 atr/templates/project-directory.html               |   2 +-
 atr/templates/project-view.html                    |  13 ++-
 11 files changed, 168 insertions(+), 88 deletions(-)

diff --git a/atr/blueprints/admin/admin.py b/atr/blueprints/admin/admin.py
index bc80a15..50cd78a 100644
--- a/atr/blueprints/admin/admin.py
+++ b/atr/blueprints/admin/admin.py
@@ -172,9 +172,10 @@ async def admin_projects_update() -> str | 
response.Response | tuple[Mapping[str
     """Update projects from remote data."""
     if quart.request.method == "POST":
         try:
-            updated_count = await _update_committees()
+            added_count, updated_count = await _update_committees()
             return {
-                "message": f"Successfully updated {updated_count} projects 
(PMCs and PPMCs) with membership data",
+                "message": f"Successfully added {added_count} and updated 
{updated_count} committees and projects "
+                f"(PMCs and PPMCs) with membership data",
                 "category": "success",
             }, 200
         except httpx.RequestError as e:
@@ -192,18 +193,21 @@ async def admin_projects_update() -> str | 
response.Response | tuple[Mapping[str
     return await quart.render_template("update-committees.html")
 
 
-async def _update_committees() -> int:
+async def _update_committees() -> tuple[int, int]:  # noqa: C901
     ldap_projects = await apache.get_ldap_projects_data()
     projects = await apache.get_projects_data()
     podlings_data = await apache.get_current_podlings_data()
+    committees = await apache.get_active_committee_data()
 
     ldap_projects_by_name: Mapping[str, LDAPProject] = {p.name: p for p in 
ldap_projects.projects}
+    committees_by_name: Mapping[str, apache.Committee] = {c.name: c for c in 
committees.committees}
 
+    added_count = 0
     updated_count = 0
 
     async with db.session() as data:
         async with data.begin():
-            # First update PMCs
+            # First create PMC committees
             for project in ldap_projects.projects:
                 name = project.name
                 # Skip non-PMC committees
@@ -215,56 +219,72 @@ async def _update_committees() -> int:
                 if not committee:
                     committee = models.Committee(name=name)
                     data.add(committee)
-                    committee_core_project = models.Project(name=name, 
committee=committee)
-
-                    project_status = projects.get(name)
-                    if project_status is not None:
-                        committee_core_project.full_name = project_status.name
-
-                    data.add(committee_core_project)
+                    added_count += 1
+                else:
+                    updated_count += 1
 
                 committee.committee_members = project.owners
                 committee.committers = project.members
-                # Ensure this is set for PMCs
+                # We create PMCs for now
                 committee.is_podling = False
-
-                # For release managers, use PMC members for now
-                # TODO: Consider a more sophisticated way to determine release 
managers
-                #       from my POV, the list of release managers should be 
the list of people
-                #       that have actually cut a release for that project
-                committee.release_managers = committee.committee_members
+                committee_info = committees_by_name.get(name)
+                if committee_info:
+                    committee.full_name = committee_info.display_name
 
                 updated_count += 1
 
-            # Then add PPMCs (podlings)
+            # Then add PPMCs and their associated project (podlings)
             for podling_name, podling_data in podlings_data:
                 # Get or create PPMC
-                podling = await data.committee(name=podling_name).get()
-                if not podling:
-                    podling = models.Committee(name=podling_name, 
is_podling=True)
-                    data.add(podling)
-                    podling_core_project = models.Project(
-                        name=podling_name, full_name=podling_data.name, 
committee=podling
-                    )
-                    data.add(podling_core_project)
-
-                # Update PPMC data from groups.json
-                podling.is_podling = True
+                ppmc = await data.committee(name=podling_name).get()
+                if not ppmc:
+                    ppmc = models.Committee(name=podling_name, is_podling=True)
+                    data.add(ppmc)
+                    added_count += 1
+                else:
+                    updated_count += 1
 
+                # We create a PPMC
+                ppmc.is_podling = True
+                ppmc.full_name = podling_data.name.removesuffix("(Incubating)")
                 podling_project = ldap_projects_by_name.get(podling_name)
                 if podling_project is not None:
-                    podling.committee_members = podling_project.owners
-                    podling.committers = podling_project.members
+                    ppmc.committee_members = podling_project.owners
+                    ppmc.committers = podling_project.members
                 else:
                     _LOGGER.warning(f"could not find ldap data for podling 
{podling_name}")
 
-                # Use PPMC members as release managers
-                # TODO: Consider a more sophisticated way to determine release 
managers
-                #       from my POV, the list of release managers should be 
the list of people
-                #       that have actually cut a release for that project
-                podling.release_managers = podling.committee_members
+                podling = await data.project(name=podling_name).get()
+                if not podling:
+                    # create the associated podling project
+                    podling = models.Project(
+                        name=podling_name, full_name=podling_data.name, 
committee=ppmc, is_podling=True
+                    )
+                    data.add(podling)
+                    added_count += 1
+                else:
+                    updated_count += 1
 
-                updated_count += 1
+                podling.full_name = podling_data.name
+                podling.committee = ppmc
+                podling.is_podling = True
+
+            # Add projects and associated them to the right PMC
+            for project_name, project_status in projects.items():
+                pmc = await data.committee(name=project_status.pmc).get()
+                if not pmc:
+                    _LOGGER.warning(f"could not find PMC for project 
{project_name}: {project_status.pmc}")
+                    continue
+
+                project_model = await data.project(name=project_name).get()
+                if not project_model:
+                    project_model = models.Project(name=project_name, 
committee=pmc, is_podling=pmc.is_podling)
+                    data.add(project_model)
+                    added_count += 1
+                else:
+                    updated_count += 1
+
+                project_model.full_name = project_status.name
 
             # Add special entry for Tooling PMC
             # Not clear why, but it's not in the Whimsy data
@@ -272,8 +292,12 @@ async def _update_committees() -> int:
             if not tooling_committee:
                 tooling_committee = models.Committee(name="tooling")
                 data.add(tooling_committee)
-                tooling_project = models.Project(name="tooling", 
committee=tooling_committee)
+                tooling_project = models.Project(
+                    name="tooling", full_name="Apache Tooling", 
committee=tooling_committee
+                )
                 data.add(tooling_project)
+                added_count += 1
+            else:
                 updated_count += 1
 
             # Update Tooling PMC data
@@ -283,7 +307,7 @@ async def _update_committees() -> int:
             tooling_committee.release_managers = ["wave"]
             tooling_committee.is_podling = False
 
-    return updated_count
+    return added_count, updated_count
 
 
 @admin.BLUEPRINT.route("/tasks")
diff --git a/atr/datasources/apache.py b/atr/datasources/apache.py
index 2d272d7..91178e4 100644
--- a/atr/datasources/apache.py
+++ b/atr/datasources/apache.py
@@ -78,10 +78,10 @@ class RetiredCommitteeData(pydantic.BaseModel):
 class Committee(pydantic.BaseModel):
     name: str
     display_name: str
-    site: str
+    site: str | None
     description: str
     mail_list: str
-    established: str
+    established: str | None
     report: list[str]
     chair: Annotated[list[User], util.DictToList(key="id")]
     roster_count: int
diff --git a/atr/db/__init__.py b/atr/db/__init__.py
index c3c3389..2097ed2 100644
--- a/atr/db/__init__.py
+++ b/atr/db/__init__.py
@@ -128,6 +128,7 @@ class Session(sqlalchemy.ext.asyncio.AsyncSession):
         release_managers: Opt[list[str]] = NotSet,
         vote_policy_id: Opt[int] = NotSet,
         name_in: Opt[list[str]] = NotSet,
+        _projects: bool = False,
         _public_signing_keys: bool = False,
         _vote_policy: bool = False,
     ) -> Query[models.Committee]:
@@ -156,6 +157,8 @@ class Session(sqlalchemy.ext.asyncio.AsyncSession):
             models_committee_name = 
validate_instrumented_attribute(models.Committee.name)
             query = query.where(models_committee_name.in_(name_in))
 
+        if _projects:
+            query = query.options(select_in_load(models.Committee.projects))
         if _public_signing_keys:
             query = 
query.options(select_in_load(models.Committee.public_signing_keys))
         if _vote_policy:
diff --git a/atr/db/models.py b/atr/db/models.py
index 09c675b..f95bf92 100644
--- a/atr/db/models.py
+++ b/atr/db/models.py
@@ -115,7 +115,7 @@ class Committee(sqlmodel.SQLModel, table=True):
     def display_name(self) -> str:
         """Get the display name for the committee."""
         name = self.name if self.full_name is None else self.full_name
-        return f"{name} (podling)" if self.is_podling else name
+        return f"{name} (PPMC)" if self.is_podling else name
 
 
 class Project(sqlmodel.SQLModel, table=True):
@@ -146,7 +146,7 @@ class Project(sqlmodel.SQLModel, table=True):
     def display_name(self) -> str:
         """Get the display name for the Project."""
         name = self.name if self.full_name is None else self.full_name
-        return f"{name} (podling)" if self.is_podling else name
+        return name
 
     @property
     async def editable_releases(self) -> list["Release"]:
diff --git a/atr/routes/committees.py b/atr/routes/committees.py
new file mode 100644
index 0000000..cd5d1f5
--- /dev/null
+++ b/atr/routes/committees.py
@@ -0,0 +1,43 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""project.py"""
+
+import http.client
+
+import quart
+
+import atr.db as db
+import atr.db.models as models
+import atr.routes as routes
+
+
[email protected]_route("/committees")
+async def root_committee_directory() -> str:
+    """Main committee directory page."""
+    async with db.session() as data:
+        committees = await 
data.committee(_projects=True).order_by(models.Committee.name).all()
+        return await quart.render_template("committee-directory.html", 
committees=committees)
+
+
[email protected]_route("/committees/<name>")
+async def root_committee_view(name: str) -> str:
+    async with db.session() as data:
+        committee = await data.committee(
+            name=name, _projects=True, _public_signing_keys=True, 
_vote_policy=True
+        ).demand(http.client.HTTPException(404))
+        return await quart.render_template("committee-view.html", 
committee=committee, algorithms=routes.algorithms)
diff --git a/atr/server.py b/atr/server.py
index ea3b6bc..5a03cb9 100644
--- a/atr/server.py
+++ b/atr/server.py
@@ -57,6 +57,7 @@ class ApiOnlyOpenAPIProvider(quart_schema.OpenAPIProvider):
 def register_routes(app: base.QuartApp) -> tuple[str, ...]:
     # NOTE: These imports are for their side effects only
     import atr.routes.candidate as candidate
+    import atr.routes.committees as committees
     import atr.routes.dev as dev
     import atr.routes.docs as docs
     import atr.routes.download as download
@@ -95,6 +96,7 @@ def register_routes(app: base.QuartApp) -> tuple[str, ...]:
     # Must do this otherwise ruff "fixes" this function by removing the imports
     return (
         candidate.__name__,
+        committees.__name__,
         dev.__name__,
         docs.__name__,
         download.__name__,
diff --git a/atr/templates/project-directory.html 
b/atr/templates/committee-directory.html
similarity index 61%
copy from atr/templates/project-directory.html
copy to atr/templates/committee-directory.html
index 2665ddc..a7cf0f9 100644
--- a/atr/templates/project-directory.html
+++ b/atr/templates/committee-directory.html
@@ -1,16 +1,16 @@
 {% extends "layouts/base.html" %}
 
 {% block title %}
-  Project directory ~ ATR
+  Committee directory ~ ATR
 {% endblock title %}
 
 {% block description %}
-  List of all ASF projects and their latest releases.
+  List of all ASF committees and their associated projects.
 {% endblock description %}
 
 {% block content %}
   <h1>Project directory</h1>
-  <p class="intro">Current ASF projects and their releases:</p>
+  <p class="intro">Current ASF committees and their projects:</p>
 
   <div class="mb-3">
     <input type="text"
@@ -20,34 +20,20 @@
   </div>
 
   <div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4">
-    {% for project in projects %}
+    {% for committee in committees %}
       <div class="col">
         <div class="card h-100 shadow-sm atr-cursor-pointer hover-lift 
project-card"
-             data-project-url="{{ url_for('root_project_view', 
name=project.name) }}">
+             data-project-url="{{ url_for('root_committee_view', 
name=committee.name) }}">
           <div class="card-body">
-            <h2 class="card-title fs-4 mb-3">{{ project.display_name }}</h2>
             <div class="row g-3">
-              <div class="col-4">
-                <div class="card h-100 bg-light border-0">
-                  <div class="card-body p-2 d-flex flex-column 
justify-content-between text-center">
-                    <small class="text-secondary">Project committee 
members</small>
-                    <span class="fs-4 fw-medium mt-2">{{ 
project.committee.committee_members|length }}</span>
-                  </div>
-                </div>
-              </div>
-              <div class="col-4">
-                <div class="card h-100 bg-light border-0">
-                  <div class="card-body p-2 d-flex flex-column 
justify-content-between text-center">
-                    <small class="text-secondary">Committers</small>
-                    <span class="fs-4 fw-medium mt-2">{{ 
project.committee.committers|length }}</span>
-                  </div>
-                </div>
+              <div class="col-md">
+                <h3 class="card-title fs-4 mb-3 position-absolute top-50 
translate-middle-y">{{ committee.display_name }}</h3>
               </div>
-              <div class="col-4">
+              <div class="col-3">
                 <div class="card h-100 bg-light border-0">
                   <div class="card-body p-2 d-flex flex-column 
justify-content-between text-center">
-                    <small class="text-secondary">Release Managers</small>
-                    <span class="fs-4 fw-medium mt-2">{{ 
project.release_managers|length }}</span>
+                    <small class="text-secondary">Projects</small>
+                    <span class="fs-4 fw-medium mt-2">{{ 
committee.projects|length }}</span>
                   </div>
                 </div>
               </div>
diff --git a/atr/templates/project-view.html b/atr/templates/committee-view.html
similarity index 84%
copy from atr/templates/project-view.html
copy to atr/templates/committee-view.html
index 3b0a5d0..66bca89 100644
--- a/atr/templates/project-view.html
+++ b/atr/templates/committee-view.html
@@ -1,15 +1,15 @@
 {% extends "layouts/base.html" %}
 
 {% block title %}
-  Project ~ ATR
+  Committee ~ ATR
 {% endblock title %}
 
 {% block description %}
-  Release candidates to which you have access.
+  Information regarding an Apache Committee.
 {% endblock description %}
 
 {% block content %}
-  <h1>{{ project.display_name | capitalize }}</h1>
+  <h1>{{ committee.display_name | capitalize }}</h1>
 
   <div class="card mb-4">
     <div class="card-header bg-light">
@@ -17,21 +17,36 @@
     </div>
     <div class="card-body">
       <div class="d-flex flex-wrap gap-3 small mb-1">
-        <span>Committee members: {{ project.committee.committee_members|length 
}}</span>
+        <span>Committee members: {{ committee.committee_members|length 
}}</span>
         <span class="d-flex align-items-center">
-          <span>Committers: {{ project.committee.committers|length }}</span>
+          <span>Committers: {{ committee.committers|length }}</span>
         </span>
       </div>
     </div>
   </div>
 
+  <div class="card mb-4">
+    <div class="card-header bg-light">
+      <h3 class="mb-0">Projects</h3>
+    </div>
+    <div class="card-body">
+      <ul>
+        {% for project in committee.projects %}
+          <li>
+            <a href="{{ url_for('root_project_view', name=project.name) }}">{{ 
project.display_name }}</a>
+          </li>
+        {% endfor %}
+      </ul>
+    </div>
+  </div>
+
   <div class="card mb-4">
     <div class="card-header bg-light">
       <h3 class="mb-2">Signing Keys</h3>
     </div>
     <div class="card-body">
       <div class="row row-cols-1 g-4">
-        {% for key in project.public_signing_keys %}
+        {% for key in committee.public_signing_keys %}
           <div class="col">
             <div class="card h-100 border">
               <div class="card-body">
@@ -91,12 +106,12 @@
       <h3 class="mb-0">Voting Policy</h3>
       <div>
         <a class="btn btn-primary"
-           href="{{ url_for('root_project_voting_policy_add', 
name=project.name) }}"><i class="fa-solid fa-plus"></i></a>
+           href="{{ url_for('root_project_voting_policy_add', 
name=committee.name) }}"><i class="fa-solid fa-plus"></i></a>
       </div>
     </div>
     <div class="card-body">
-      {% if project.vote_policy %}
-        {% set vp = project.vote_policy %}
+      {% if committee.vote_policy %}
+        {% set vp = committee.vote_policy %}
         <div class="card border">
           <div class="card-body">
             <table class="table mb-0">
@@ -113,15 +128,6 @@
     </div>
   </div>
 
-  <!-- TODO: Subprojects?
-  <div class="card mb-4">
-    <div class="card-header bg-light">
-      <h3 class="mb-0">Projects</h3>
-    </div>
-    <div class="card-body"></div>
-  </div>
-  -->
-
 {% endblock content %}
 
 {% block javascripts %}
diff --git a/atr/templates/includes/sidebar.html 
b/atr/templates/includes/sidebar.html
index ce5f960..50e4512 100644
--- a/atr/templates/includes/sidebar.html
+++ b/atr/templates/includes/sidebar.html
@@ -34,6 +34,11 @@
         <a href="{{ url_for('root') }}"
            {% if request.endpoint == 'root' %}class="active"{% endif 
%}>About</a>
       </li>
+      <li>
+        <i class="fa-solid fa-diagram-project"></i>
+        <a href="{{ url_for('root_committee_directory') }}"
+           {% if request.endpoint == 'root_committee_directory' 
%}class="active"{% endif %}>Committees</a>
+      </li>
       <li>
         <i class="fa-solid fa-diagram-project"></i>
         <a href="{{ url_for('root_project_directory') }}"
diff --git a/atr/templates/project-directory.html 
b/atr/templates/project-directory.html
index 2665ddc..1210166 100644
--- a/atr/templates/project-directory.html
+++ b/atr/templates/project-directory.html
@@ -25,7 +25,7 @@
         <div class="card h-100 shadow-sm atr-cursor-pointer hover-lift 
project-card"
              data-project-url="{{ url_for('root_project_view', 
name=project.name) }}">
           <div class="card-body">
-            <h2 class="card-title fs-4 mb-3">{{ project.display_name }}</h2>
+            <h3 class="card-title fs-4 mb-3">{{ project.display_name }}</h3>
             <div class="row g-3">
               <div class="col-4">
                 <div class="card h-100 bg-light border-0">
diff --git a/atr/templates/project-view.html b/atr/templates/project-view.html
index 3b0a5d0..72d569c 100644
--- a/atr/templates/project-view.html
+++ b/atr/templates/project-view.html
@@ -5,12 +5,23 @@
 {% endblock title %}
 
 {% block description %}
-  Release candidates to which you have access.
+  Information regarding an Apache Project.
 {% endblock description %}
 
 {% block content %}
   <h1>{{ project.display_name | capitalize }}</h1>
 
+  <div class="card mb-4">
+    <div class="card-header bg-light">
+      <h3 class="mb-2">PMC</h3>
+    </div>
+    <div class="card-body">
+      <div class="d-flex flex-wrap gap-3 small mb-1">
+        <a href="{{ url_for('root_committee_view', 
name=project.committee.name) }}">{{ project.committee.display_name }}</a>
+      </div>
+    </div>
+  </div>
+
   <div class="card mb-4">
     <div class="card-header bg-light">
       <h3 class="mb-2">Members</h3>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to