Skip to content

Commit

Permalink
feat: Improve feature models counter
Browse files Browse the repository at this point in the history
  • Loading branch information
drorganvidez committed Jul 7, 2024
1 parent fddc0e1 commit 89a894a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions app/modules/dataset/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ class FeatureModelRepository(BaseRepository):
def __init__(self):
super().__init__(FeatureModel)

def count_feature_models(self) -> int:
max_id = self.model.query.with_entities(func.max(self.model.id)).scalar()
return max_id if max_id is not None else 0


class FileRepository(BaseRepository):
def __init__(self):
Expand Down
5 changes: 4 additions & 1 deletion app/modules/dataset/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def count_synchronized_datasets(self):
return self.repository.count_synchronized_datasets()

def count_feature_models(self):
return self.feature_model_service.count()
return self.feature_model_service.count_feature_models()

def count_authors(self) -> int:
return self.author_repository.count()
Expand All @@ -68,6 +68,9 @@ class FeatureModelService(BaseService):
def __init__(self):
super().__init__(FeatureModelRepository())

def count_feature_models(self):
return self.repository.count_feature_models()


class AuthorService(BaseService):
def __init__(self):
Expand Down
5 changes: 3 additions & 2 deletions app/modules/public/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from flask import render_template

from app.modules.public import public_bp
from app.modules.dataset.services import DataSetService
from app.modules.dataset.services import DataSetService, FeatureModelService

logger = logging.getLogger(__name__)

Expand All @@ -12,10 +12,11 @@
def index():
logger.info("Access index")
dataset_service = DataSetService()
feature_model_service = FeatureModelService()

# Statistics: total datasets and feature models
datasets_counter = dataset_service.count_synchronized_datasets()
feature_models_counter = dataset_service.count_feature_models()
feature_models_counter = feature_model_service.count_feature_models()

# Statistics: total downloads
total_dataset_downloads = dataset_service.total_dataset_downloads()
Expand Down

0 comments on commit 89a894a

Please sign in to comment.