
from bootstrap import manager

from web import models
from web.views.api.v1 import processors
from web.views.api.v1.common import url_prefix


blueprint_cve = manager.create_api_blueprint(
    models.CVE,
    url_prefix=url_prefix,
    methods=['GET'])


from bootstrap import manager

from web import models
from web.views.api.v1 import processors
from web.views.api.v1.common import url_prefix

def pre_get_many(search_params=None, **kw):
    order_by = [{"field":"published_at", "direction":"desc"}]
    if 'order_by' not in search_params:
        search_params['order_by'] = []
    search_params['order_by'].extend(order_by)

blueprint_cve = manager.create_api_blueprint(
    models.CVE,
    url_prefix=url_prefix,
    methods=['GET'],
    preprocessors=dict(
        GET_MANY=[pre_get_many]))

Sort CVE by published_at attribute.
[API] Sort CVE by published_at attribute.

  
  from bootstrap import manager
  
  from web import models
  from web.views.api.v1 import processors
  from web.views.api.v1.common import url_prefix
  
+ def pre_get_many(search_params=None, **kw):
+     order_by = [{"field":"published_at", "direction":"desc"}]
+     if 'order_by' not in search_params:
+         search_params['order_by'] = []
+     search_params['order_by'].extend(order_by)
  
  blueprint_cve = manager.create_api_blueprint(
      models.CVE,
      url_prefix=url_prefix,
-     methods=['GET'])
+     methods=['GET'],
+     preprocessors=dict(
+         GET_MANY=[pre_get_many]))
  
Sort CVE by published_at attribute.
## Code Before:

from bootstrap import manager

from web import models
from web.views.api.v1 import processors
from web.views.api.v1.common import url_prefix


blueprint_cve = manager.create_api_blueprint(
    models.CVE,
    url_prefix=url_prefix,
    methods=['GET'])

## Instruction:
Sort CVE by published_at attribute.
## Code After:

from bootstrap import manager

from web import models
from web.views.api.v1 import processors
from web.views.api.v1.common import url_prefix

def pre_get_many(search_params=None, **kw):
    order_by = [{"field":"published_at", "direction":"desc"}]
    if 'order_by' not in search_params:
        search_params['order_by'] = []
    search_params['order_by'].extend(order_by)

blueprint_cve = manager.create_api_blueprint(
    models.CVE,
    url_prefix=url_prefix,
    methods=['GET'],
    preprocessors=dict(
        GET_MANY=[pre_get_many]))
