Skip to content

Commit

Permalink
[PackagePostgres] add get_analysis_count(ecosystem, package)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpopelka committed Jun 7, 2017
1 parent 24173a3 commit 719f8d6
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 719f8d6

Please sign in to comment.