[csw-devel] SF.net SVN: gar:[21924] csw/mgar/gar/v2/lib

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sat Sep 14 17:37:02 CEST 2013


Revision: 21924
          http://gar.svn.sourceforge.net/gar/?rev=21924&view=rev
Author:   wahwah
Date:     2013-09-14 15:37:02 +0000 (Sat, 14 Sep 2013)
Log Message:
-----------
pkgdb-web: Add an endpoint with catalog timing inf

This can be used to find out when a given package was inserted in a given
catalog.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/models.py
    csw/mgar/gar/v2/lib/web/pkgdb_web.py

Modified: csw/mgar/gar/v2/lib/python/models.py
===================================================================
--- csw/mgar/gar/v2/lib/python/models.py	2013-09-14 15:36:50 UTC (rev 21923)
+++ csw/mgar/gar/v2/lib/python/models.py	2013-09-14 15:37:02 UTC (rev 21924)
@@ -519,7 +519,14 @@
        'size',
        'deps',
        'i_deps',
-       'pkginfo_name'],
+       'pkginfo_name',
+       # The above columns are used to generate catalogs.
+       # Additional columns can be added blow.
+       'maintainer_id',
+       'mtime',
+       'created_on',
+       'created_by',
+       ],
       where=where,
       orderBy='catalogname',
       join=join)

Modified: csw/mgar/gar/v2/lib/web/pkgdb_web.py
===================================================================
--- csw/mgar/gar/v2/lib/web/pkgdb_web.py	2013-09-14 15:36:50 UTC (rev 21923)
+++ csw/mgar/gar/v2/lib/web/pkgdb_web.py	2013-09-14 15:37:02 UTC (rev 21924)
@@ -50,6 +50,8 @@
       'PkgnamesAndPathsByBasedir',  # with ?basedir=...
   r'/rest/catalogs/([^/]+)/(sparc|i386)/(SunOS[^/]+)/for-generation/',
       'CatalogForGeneration',
+  r'/rest/catalogs/([^/]+)/(sparc|i386)/(SunOS[^/]+)/timing/',
+      'CatalogTiming',
   # Query by catalog release, arch, OS release and catalogname
   r'/rest/catalogs/([^/]+)/(sparc|i386)/(SunOS[^/]+)/catalognames/([^/]+)/',
       'Srv4ByCatAndCatalogname',
@@ -614,6 +616,39 @@
     return response
 
 
+class CatalogTiming(object):
+
+  def GET(self, catrel_name, arch_name, osrel_name):
+    """A list of tuples, aligning with the catalog format.
+
+    catalogname version_string pkgname
+    basename md5_sum size deps category i_deps
+    """
+    sqo_osrel, sqo_arch, sqo_catrel = models.GetSqoTriad(
+        osrel_name, arch_name, catrel_name)
+    rows = list(models.GetCatalogGenerationResult(sqo_osrel, sqo_arch, sqo_catrel))
+    def PrepareForJson(row):
+      # The size (5th row) is returned as a large integer, which cannot be represented
+      # in JSON.
+      # 'maintainer', #9
+      # 'mtime',      #10
+      # 'created_on', #11
+      # 'created_by', #12
+      newrow = list(row)
+      newrow[5] = int(newrow[5])
+      newrow[6] = cjson.decode(newrow[6])
+      newrow[7] = cjson.decode(newrow[7])
+      if newrow[10]:
+        newrow[10] = newrow[10].isoformat()
+      if newrow[11]:
+        newrow[11] = newrow[11].isoformat()
+      return newrow
+    rows = [PrepareForJson(x) for x in rows]
+    response = cjson.encode(rows)
+    web.header('Content-Length', str(len(response)))
+    return response
+
+
 web.webapi.internalerror = web.debugerror
 
 

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list