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 baf94da  remove deprecated db methods, remove unused db service 
module, update custom bootstrap theme to not use w-25 for table headers
baf94da is described below

commit baf94da60a68747db793d4838037617ec0cea9e5
Author: Thomas Neidhart <[email protected]>
AuthorDate: Tue Apr 1 10:33:54 2025 +0200

    remove deprecated db methods, remove unused db service module, update 
custom bootstrap theme to not use w-25 for table headers
---
 atr/blueprints/admin/templates/tasks.html | 20 ++++++--
 atr/blueprints/api/api.py                 | 18 +++++--
 atr/db/__init__.py                        | 23 ---------
 atr/db/service.py                         | 82 -------------------------------
 atr/static/css/bootstrap.custom.css       |  2 +-
 bootstrap/custom.scss                     |  1 -
 6 files changed, 32 insertions(+), 114 deletions(-)

diff --git a/atr/blueprints/admin/templates/tasks.html 
b/atr/blueprints/admin/templates/tasks.html
index 1e3143b..b9b0ad0 100644
--- a/atr/blueprints/admin/templates/tasks.html
+++ b/atr/blueprints/admin/templates/tasks.html
@@ -29,22 +29,36 @@
   <script>
     new gridjs.Grid({
       columns: [
-        'ID',
-        'Task Type',
-        'Task Status',
+        {
+            name: 'ID',
+            width: '40px'
+        },
+        {
+            name: 'Task Type',
+            width: '140px'
+        },
+        {
+            name: 'Task Status',
+            width: '60px'
+        },
         {
           name: 'Added',
+          width: '100px',
           formatter: (cell) => `${new Date(cell).toISOString()}`
         },
         {
           name: 'Started',
+          width: '100px',
           formatter: (cell) => `${new Date(cell).toISOString()}`
         },
         {
           name: 'Completed',
+          width: '100px',
           formatter: (cell) => `${new Date(cell).toISOString()}`
         }
       ],
+      autoWidth: false,
+      resizable: true,
       style: {
         table: {
           // TODO: Need a better fix here
diff --git a/atr/blueprints/api/api.py b/atr/blueprints/api/api.py
index e93f887..9bc1118 100644
--- a/atr/blueprints/api/api.py
+++ b/atr/blueprints/api/api.py
@@ -20,12 +20,14 @@ from collections.abc import Mapping
 
 import quart
 import quart_schema
+import sqlalchemy
+import sqlalchemy.ext.asyncio
+import sqlmodel
 import werkzeug.exceptions as exceptions
 
 import atr.blueprints.api as api
 import atr.db as db
 import atr.db.models as models
-import atr.db.service as service
 
 # FIXME: we need to return the dumped model instead of the actual pydantic 
class
 #        as otherwise pyright will complain about the return type
@@ -59,6 +61,14 @@ class Pagination:
 @api.BLUEPRINT.route("/tasks")
 @quart_schema.validate_querystring(Pagination)
 async def api_tasks(query_args: Pagination) -> quart.Response:
-    paged_tasks, count = await service.get_tasks(limit=query_args.limit, 
offset=query_args.offset)
-    result = {"data": [x.model_dump(exclude={"result"}) for x in paged_tasks], 
"count": count}
-    return quart.jsonify(result)
+    async with db.session() as data:
+        statement = (
+            sqlmodel.select(models.Task)
+            .limit(query_args.limit)
+            .offset(query_args.offset)
+            .order_by(models.Task.id.desc())  # type: ignore
+        )
+        paged_tasks = (await data.execute(statement)).scalars().all()
+        count = (await 
data.execute(sqlalchemy.select(sqlalchemy.func.count(models.Task.id)))).scalar_one()
  # type: ignore
+        result = {"data": [x.model_dump(exclude={"result"}) for x in 
paged_tasks], "count": count}
+        return quart.jsonify(result)
diff --git a/atr/db/__init__.py b/atr/db/__init__.py
index cda85c4..92ab0d4 100644
--- a/atr/db/__init__.py
+++ b/atr/db/__init__.py
@@ -554,29 +554,6 @@ def create_async_db_session() -> 
sqlalchemy.ext.asyncio.AsyncSession:
         return util.validate_as_type(_global_async_sessionmaker(), 
sqlalchemy.ext.asyncio.AsyncSession)
 
 
-# FIXME: this method is deprecated and should be removed
-def create_sync_db_engine() -> None:
-    """Create a synchronous database engine."""
-
-    global _global_sync_engine
-
-    conf = config.get()
-    sqlite_url = f"sqlite://{conf.SQLITE_DB_PATH}"
-    _LOGGER.debug(f"Creating sync database engine in process {os.getpid()}")
-    _global_sync_engine = sqlalchemy.create_engine(sqlite_url, echo=False)
-
-
-# FIXME: this method is deprecated and should be removed
-def create_sync_db_session() -> sqlalchemy.orm.Session:
-    """Create a new synchronous database session."""
-    global _global_sync_engine
-    if _global_sync_engine is None:
-        conf = config.get()
-        sqlite_url = f"sqlite://{conf.SQLITE_DB_PATH}"
-        _global_sync_engine = sqlalchemy.create_engine(sqlite_url, echo=False)
-    return sqlalchemy.orm.Session(_global_sync_engine)
-
-
 async def recent_tasks(data: Session, release_name: str, file_path: str, 
modified: int) -> dict[str, models.Task]:
     """Get the most recent task for each task type for a specific file."""
     tasks = await data.task(
diff --git a/atr/db/service.py b/atr/db/service.py
deleted file mode 100644
index 61f9d22..0000000
--- a/atr/db/service.py
+++ /dev/null
@@ -1,82 +0,0 @@
-# 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.
-
-import contextlib
-from collections.abc import Sequence
-
-import sqlalchemy
-import sqlalchemy.ext.asyncio
-import sqlmodel
-
-import atr.db as db
-import atr.db.models as models
-
-
-async def get_committee_by_name(
-    name: str, session: sqlalchemy.ext.asyncio.AsyncSession | None = None
-) -> models.Committee | None:
-    """Returns a Committee object by name."""
-    async with db.create_async_db_session() if session is None else 
contextlib.nullcontext(session) as db_session:
-        statement = 
sqlmodel.select(models.Committee).where(models.Committee.name == name)
-        committee = (await db_session.execute(statement)).scalar_one_or_none()
-        return committee
-
-
-async def get_committees(session: sqlalchemy.ext.asyncio.AsyncSession | None = 
None) -> Sequence[models.Committee]:
-    """Returns a list of Committee objects."""
-    async with db.create_async_db_session() if session is None else 
contextlib.nullcontext(session) as db_session:
-        # Get all Committees
-        statement = 
sqlmodel.select(models.Committee).order_by(models.Committee.name)
-        committees = (await db_session.execute(statement)).scalars().all()
-        return committees
-
-
-async def get_release_by_name(name: str) -> models.Release | None:
-    """Get a release by its name."""
-    async with db.create_async_db_session() as db_session:
-        # Get the release
-        query = (
-            sqlmodel.select(models.Release)
-            .where(models.Release.name == name)
-            .options(db.select_in_load_nested(models.Release.project, 
models.Project.committee))
-        )
-        result = await db_session.execute(query)
-        return result.scalar_one_or_none()
-
-
-def get_release_by_name_sync(name: str) -> models.Release | None:
-    """Synchronous version of get_release_by_name for use in background 
tasks."""
-    with db.create_sync_db_session() as session:
-        # Get the release
-        query = (
-            sqlmodel.select(models.Release)
-            .where(models.Release.name == name)
-            .options(db.select_in_load_nested(models.Release.project, 
models.Project.committee))
-        )
-        result = session.execute(query)
-        return result.scalar_one_or_none()
-
-
-async def get_tasks(
-    limit: int, offset: int, session: sqlalchemy.ext.asyncio.AsyncSession | 
None = None
-) -> tuple[Sequence[models.Task], int]:
-    """Returns a list of Tasks based on limit and offset values together with 
the total count."""
-    async with db.create_async_db_session() if session is None else 
contextlib.nullcontext(session) as db_session:
-        statement = 
sqlmodel.select(models.Task).limit(limit).offset(offset).order_by(models.Task.id.desc())
  # type: ignore
-        tasks = (await db_session.execute(statement)).scalars().all()
-        count = (await 
db_session.execute(sqlalchemy.select(sqlalchemy.func.count(models.Task.id)))).scalar_one()
  # type: ignore
-        return tasks, count
diff --git a/atr/static/css/bootstrap.custom.css 
b/atr/static/css/bootstrap.custom.css
index 9f0a5c4..62722d6 100644
--- a/atr/static/css/bootstrap.custom.css
+++ b/atr/static/css/bootstrap.custom.css
@@ -7131,7 +7131,7 @@ textarea.form-control-lg {
   --bs-border-opacity: 1;
 }
 
-.w-25, th {
+.w-25 {
   width: 25% !important;
 }
 
diff --git a/bootstrap/custom.scss b/bootstrap/custom.scss
index a6a7b44..fa3ac83 100644
--- a/bootstrap/custom.scss
+++ b/bootstrap/custom.scss
@@ -67,7 +67,6 @@ th {
   color: $dark;
   font-weight: 525;
   @extend .align-middle;
-  @extend .w-25;
 }
 
 // Not in Bootstrap


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

Reply via email to