Skip to content

Commit

Permalink
Merge pull request #40 from jpopelka/package-pgsql-an-count
Browse files Browse the repository at this point in the history
[PackagePostgres] add get_analysis_count(ecosystem, package)
  • Loading branch information
fridex authored Jun 7, 2017
2 parents 24173a3 + 719f8d6 commit fb53421
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cucoslib/storages/package_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,21 @@ def get_analysis_by_id(self, analysis_id):
one()

return found

def get_analysis_count(self, ecosystem, package):
"""Get count of previously scheduled analyses for given ecosystem-package.
:param ecosystem: str, Ecosystem name
:param package: str, Package name
:return: analysis count
"""
if ecosystem == 'maven':
package = MavenCoordinates.normalize_str(package)

count = self.session.query(PackageAnalysis).\
join(Package).join(Ecosystem).\
filter(Ecosystem.name == ecosystem).\
filter(Package.name == package).\
count()

return count

0 comments on commit fb53421

Please sign in to comment.