From 3cce0a9dc54018016a01f4f817cef3c05139425f Mon Sep 17 00:00:00 2001 From: Oleksandr Date: Thu, 8 Feb 2024 19:08:51 +0100 Subject: [PATCH] pr updates Co-authored-by: Donald Campbell <125581724+donaldcampbelljr@users.noreply.github.com> --- .github/workflows/pytest.yml | 2 +- README.md | 12 +++++------- pepdbagent/modules/namespace.py | 12 ++++++------ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index cca2c4f..16f6d0b 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -33,7 +33,7 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Install dev dependancies + - name: Install dev dependencies run: if [ -f requirements/requirements-dev.txt ]; then pip install -r requirements/requirements-dev.txt; fi - name: Install package diff --git a/README.md b/README.md index 01663ac..27a5073 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@

pepdbagent

-

[![PEP compatible](https://pepkit.github.io/img/PEP-compatible-green.svg)](https://pep.databio.org/) ![Run pytests](https://github.com/pepkit/pepdbagent/workflows/Run%20pytests/badge.svg) @@ -8,7 +7,6 @@ [![Downloads](https://static.pepy.tech/badge/pepdbagent)](https://pepy.tech/project/pepdbagent) [![Github badge](https://img.shields.io/badge/source-github-354a75?logo=github)](https://github.com/pepkit/pepdbagent) -

--- @@ -19,12 +17,12 @@ --- `pepdbagent` is a Python library and toolkit that gives a user-friendly -interface to connect, upload, update and retrieve information from pep database. This library is designed to work -to be used by PEPhub, but it can be used for any other purpose, to manage data in pep database. +interface to connect, upload, update and retrieve information from the pep database. This library is designed to work +with PEPhub, but it can be used for any other purpose. -pepdbagent creates a connection to the database and creates table schemas for the PEPhub database if necessary. +`pepdbagent` creates a connection to the database and creates table schemas for the PEPhub database if necessary. Core database is `postgres` database, but it can be easily extended to other relational databases. -To use `pepdbagent`, you need to have a database instance running with it's credentials. +To use `pepdbagent`, you need to have a database instance running with its credentials. If the version of the database schema is not compatible with the version of `pepdbagent`, it will throw an exception. ## Installation @@ -128,7 +126,7 @@ Example: # search for a specified pattern of namespace in database. agent.namespace.get(query='Namespace') -# By default all get function will retrun namespace information for public projects, +# By default all get functions will return namespace information for public projects, # To get information with private projects, admin list should be provided. # admin list means list of namespaces where user has admin rights # For example: diff --git a/pepdbagent/modules/namespace.py b/pepdbagent/modules/namespace.py index 64092e1..9616502 100644 --- a/pepdbagent/modules/namespace.py +++ b/pepdbagent/modules/namespace.py @@ -226,19 +226,19 @@ def stats(self, namespace: str = None, monthly: bool = False) -> NamespaceStats: number_of_month = 12 * 3 today_date = datetime.today().date() + timedelta(days=1) three_month_ago = today_date - timedelta(days=number_of_month * 30 + 1) - statement_update = select(Projects.last_update_date).filter( + statement_last_update = select(Projects.last_update_date).filter( Projects.last_update_date.between(three_month_ago, today_date) ) - statement_create = select(Projects.submission_date).filter( + statement_create_date = select(Projects.submission_date).filter( Projects.submission_date.between(three_month_ago, today_date) ) if namespace: - statement_update = statement_update.where(Projects.namespace == namespace) - statement_create = statement_create.where(Projects.namespace == namespace) + statement_last_update = statement_last_update.where(Projects.namespace == namespace) + statement_create_date = statement_create_date.where(Projects.namespace == namespace) with Session(self._sa_engine) as session: - update_results = session.execute(statement_update).all() - create_results = session.execute(statement_create).all() + update_results = session.execute(statement_last_update).all() + create_results = session.execute(statement_create_date).all() if monthly: year_month_str_submission = [