old_contents: """
  Article model class
  """
  
  from flickipedia.config import log, schema
  from flickipedia.mysqlio import DataIOMySQL
  
  
  class ArticleModel(object):
  
      def __init__(self):
          super(ArticleModel, self).__init__()
  
          self.io = DataIOMySQL()
          self.io.connect()
  
      def get_article_by_name(self, article):
          """
          Fetch Article
  
              :param article: str, article name
  
              :return:        Article schema object or None
          """
          schema_obj = getattr(schema, 'Article')
          res = self.io.session.query(schema_obj).filter(
              schema_obj.article_name == article).all()
          if len(res) > 0:
              return res[0]
          else:
              return None
  
      def insert_article(self, article, pageid):
          return self.io.insert('Article', wiki_aid=pageid, article_name=article)
  
      def get_most_recently_accessed(self):
          pass
  
new_contents: """
  Article model class
  """
  
  import time
  
  from flickipedia.config import log, schema
  from flickipedia.mysqlio import DataIOMySQL
  
  
  class ArticleModel(object):
  
      def __init__(self):
          super(ArticleModel, self).__init__()
  
          self.io = DataIOMySQL()
          self.io.connect()
  
      def get_article_by_name(self, article):
          """
          Fetch Article
  
              :param article: str, article name
  
              :return:        Article schema object or None
          """
          schema_obj = getattr(schema, 'Article')
          res = self.io.session.query(schema_obj).filter(
              schema_obj.article_name == article).all()
          if len(res) > 0:
              return res[0]
          else:
              return None
  
      def insert_article(self, article, pageid):
          return self.io.insert('Article', wiki_aid=pageid,
              article_name=article, last_access=int(time.time()))
  
      def get_most_recently_accessed(self, limit):
          """Retrieve most recently accessed articles"""
          schema_obj = getattr(schema, 'Article')
          return self.io.session.query(schema_obj).order_by(
              schema_obj.last_access.desc()).limit(limit).all()
  
      def update_last_access(self, id):
          """Update the last access time"""
          schema_obj = getattr(schema, 'Article')
          self.io.session.query(schema_obj).filter(schema_obj.id == id).update(
                  {schema_obj.last_access: int(time.time())})
          self.io.session.commit()
  
subject: add - implementations for get_most_recently_accessed and update_last_access via ORM