Esempio n. 1
0
 def getArticles(self, type, startPage, limit):
     mongoService = MongoService()
     listArticles = []
     start = (startPage - 1) * config.pageSize
     mark = common.getMark()
     listArticles = mongoService.getListArticles(type, start, limit, mark)
     return listArticles
Esempio n. 2
0
 def getArticles(self, type, startPage, limit):
     mongoService=MongoService()
     listArticles=[]
     start = (startPage-1)*config.pageSize
     mark = common.getMark()
     listArticles=mongoService.getListArticles(type, start, limit, mark)
     return listArticles
Esempio n. 3
0
 def getArticles(self, themes_array, limits):
     mongoService=MongoService()
     array=[]
     mark = common.getMark()
     for theme in themes_array:
         listArticles=mongoService.getMainArticles(theme["theme_id"], limits, mark)
         array.extend(listArticles)
     return array
 def getArticles(self, type, limit):
     redisService = RedisService(self.log)
     mark = redisService.getArticlesMark()
     service = MongoService(self.log)
     articles = service.getArticles(type, limit, mark)
     return articles
Esempio n. 5
0
 def getArticle(self, articleId):
     mark = common.getMark()
     mongoService = MongoService()
     article = mongoService.getArticles(articleId, mark)
     return article
Esempio n. 6
0
 def getListArticlesSum(self, type):
     mark = common.getMark()
     mongoService = MongoService()
     sum = mongoService.getListArticlesSum(type, mark)
     return sum
Esempio n. 7
0
 def getThemeTitle(self, themeId):
     mongoService = MongoService()
     title = mongoService.getThemeTitle(themeId)
     return title
 def getArticle(self, articleId):
     mark = common.getMark()
     mongoService = MongoService()
     article = mongoService.getArticles(articleId, mark)
     return article
Esempio n. 9
0
 def getListArticlesSum(self, type):
     mark = common.getMark()
     mongoService=MongoService()
     sum = mongoService.getListArticlesSum(type, mark)
     return sum
Esempio n. 10
0
 def getThemeTitle(self,themeId):
     mongoService=MongoService()
     title = mongoService.getThemeTitle(themeId)
     return title
Esempio n. 11
0
 def getArticles(self, type, limit):
     redisService = RedisService(self.log)
     mark = redisService.getArticlesMark()
     service = MongoService(self.log)
     articles = service.getArticles(type, limit, mark)
     return articles
Esempio n. 12
0
###############################################################
# Use package flask   (pip install flask)
from flask import Flask, jsonify

from flask import abort, make_response
from flask import request
from flask import url_for

###############################################################
app = Flask(__name__)
print("app: %s" % app)

###############################################################
# Database service
from MongoService import MongoService
mongo = MongoService()
mongo.collection = "tasks"


##############################################################
# add url
def make_public_task(task):
    new_task = {}
    for field in task:
        if field == 'id':
            new_task['uri'] = url_for('get_task',
                                      task_id=task['id'],
                                      _external=True)
        #else:
        #    new_task[field] = task[field]
        new_task[field] = task[field]
Esempio n. 13
0
 def getArticle(self, articleId):
     mongoService = MongoService()
     article = mongoService.getArticles(articleId)
     return article
Esempio n. 14
0
 def getThemes(self, themes):
     mongoService=MongoService()
     return mongoService.getThemes(themes)