Skip to content

Commit

Permalink
pr updates
Browse files Browse the repository at this point in the history
Co-authored-by: Donald Campbell <125581724+donaldcampbelljr@users.noreply.github.com>
  • Loading branch information
khoroshevskyi and donaldcampbelljr committed Feb 8, 2024
1 parent d36f82c commit 3cce0a9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<h1 align="center">pepdbagent</h1>
<p align="center">

[![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)
Expand All @@ -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)

</p>

---

Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions pepdbagent/modules/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down

0 comments on commit 3cce0a9

Please sign in to comment.