Fixed for count

This commit is contained in:
Dimitris Zlatanidis 2023-05-11 21:44:40 +03:00
parent df1d32f5c9
commit 121d8f39c1

View file

@ -7,7 +7,8 @@ from slpkg.configs import Configs
from slpkg.utilities import Utilities
from slpkg.repositories import Repositories
from slpkg.models.models import session as Session
from slpkg.models.models import LastRepoUpdated, SBoTable, BinariesTable
from slpkg.models.models import (LastRepoUpdated, SBoTable,
PonceTable, BinariesTable)
class RepoInfo(Configs):
@ -38,11 +39,15 @@ class RepoInfo(Configs):
self.print_the_repositories_information()
def count_the_packages(self, repository: str) -> int:
sbo_table: dict = {
self.repos.sbo_repo_name: SBoTable,
self.repos.ponce_repo_name: PonceTable
}
if self.utils.is_binary_repo(repository):
count = self.session.query(BinariesTable).where(
BinariesTable.repo == repository).count()
else:
count = self.session.query(SBoTable.id).count()
count = self.session.query(sbo_table[repository].id).count()
self.total_packages += count