#22 Add refreshed_time endpoints
Merged 3 years ago by frantisekz. Opened 3 years ago by frantisekz.

@@ -23,17 +23,17 @@ 

  from oraculum import app, CACHE

  from oraculum.utils import cache_utils, dashboard

  

- 

  @app.route('/api/v1/packager_dashboard/<user>', methods=['GET'])

  def route_dashboard_user_data(user):

      dashboard.update_user_access_time(user)

      packages_promise = CACHE.async_get('packager-dashboard_user_data_static', 'high', user)

+     last_synced = CACHE.get_refreshed_time('packager-dashboard_user_data_static', user)

      if packages_promise == cache_utils.RefresherNotRegistered:

-         static_info = {'status': 404, 'data': None}

+         static_info = {'status': 404, 'data': None, 'last_synced': None}

      elif packages_promise == cache_utils.AsyncRefreshInProgress:

-         static_info = {'status': 204, 'data': None}

+         static_info = {'status': 204, 'data': None, 'last_synced': None}

      else:

-         static_info = {'status': 200, 'data': packages_promise}

+         static_info = {'status': 200, 'data': packages_promise, 'last_synced': last_synced}

      prs = dashboard_user_data_prs(user)

      bzs = dashboard_user_data_bzs(user)

  

@@ -67,6 +67,15 @@ 

      def _construct_what(self, item, *args, **kwargs):

          return '%s [%s, %s]' % (item, args, kwargs)

  

+     def get_refreshed_time(self, item, *args, **kwargs):

+         what = self._construct_what(item, *args, **kwargs)

+         from_db = CachedData.query.filter_by(provider=what).first()

+ 

+         if not from_db:

+             return None

+ 

+         return from_db.time_created.isoformat()

+ 

      def __get(self, synchronous, priority, item, *args, **kwargs):

          if item not in self._refreshers:

              return RefresherNotRegistered

Adds following:

  • api/v1/packager_dashboard/refreshed_time/<user> : Provides last refresh times for user static data, prs and bugs

  • api/v1/packager_dashboard/generic_data_refreshed_time : Provides last refresh times for data generic for all users

1 new commit added

  • Fixup
3 years ago

1 new commit added

  • Cleanup
3 years ago

rebased onto b9db89a

3 years ago