Skip to content

Commit

Permalink
Merge branch 'taring_namespace' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
khoroshevskyi committed Sep 6, 2024
2 parents 96e29b1 + 516de6e commit 1efb3e4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 16 deletions.
6 changes: 2 additions & 4 deletions pepdbagent/db_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,12 @@ class SchemaGroupRelations(Base):

class TarNamespace(Base):

__tablename__ = "tar_namespace"
__tablename__ = "namespace_archives"

id: Mapped[int] = mapped_column(primary_key=True)
namespace: Mapped[str] = mapped_column(ForeignKey("users.namespace", ondelete="CASCADE"))
file_path: Mapped[str] = mapped_column(nullable=False)
submission_date: Mapped[datetime.datetime] = mapped_column(default=deliver_update_date)
start_period: Mapped[datetime.datetime] = mapped_column(nullable=True)
end_period: Mapped[datetime.datetime] = mapped_column(nullable=True)
creation_date: Mapped[datetime.datetime] = mapped_column(default=deliver_update_date)
number_of_projects: Mapped[int] = mapped_column(default=0)


Expand Down
4 changes: 1 addition & 3 deletions pepdbagent/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,7 @@ class TarNamespaceModel(BaseModel):
identifier: int = None
namespace: str
file_path: str
submission_date: datetime.datetime = None
start_period: datetime.datetime
end_period: datetime.datetime
creation_date: datetime.datetime = None
number_of_projects: int = 0


Expand Down
9 changes: 3 additions & 6 deletions pepdbagent/modules/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,7 @@ def upload_tar_info(self, tar_info: TarNamespaceModel) -> None:
new_tar = TarNamespace(
file_path=tar_info.file_path,
namespace=tar_info.namespace,
start_period=tar_info.start_period,
end_period=tar_info.end_period,
creation_date=tar_info.creation_date,
number_of_projects=tar_info.number_of_projects,
)
session.add(new_tar)
Expand All @@ -337,7 +336,7 @@ def get_tar_info(self, namespace: str) -> TarNamespaceModelReturn:
tar_info = session.scalars(
select(TarNamespace)
.where(TarNamespace.namespace == namespace)
.order_by(TarNamespace.submission_date.desc())
.order_by(TarNamespace.creation_date.desc())
)

results = []
Expand All @@ -347,9 +346,7 @@ def get_tar_info(self, namespace: str) -> TarNamespaceModelReturn:
identifier=result.id,
namespace=result.namespace,
file_path=result.file_path,
start_period=result.start_period,
end_period=result.end_period,
submission_date=result.submission_date,
creation_date=result.creation_date,
number_of_projects=result.number_of_projects,
)
)
Expand Down
3 changes: 0 additions & 3 deletions tests/test_tar_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ def test_create_meta_tar(self):
result = agent.namespace.get_tar_info(namespace=self.test_namespace)

assert result.count == 1
assert result.results[0].end_period.strftime(
"%Y:%m:%d"
) == self.tar_info.end_period.strftime("%Y:%m:%d")

def test_delete_meta_tar(self):
with PEPDBAgentContextManager(add_data=True) as agent:
Expand Down

0 comments on commit 1efb3e4

Please sign in to comment.