Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Strings params:
- * @var classType
- * @var tabTag
- * @var sortTag
- * @var skipCount
- * @var mcVersion
- *
- * add Header Item Object
- * resultList.push('Try these apps:')
- *
- */
- Parse.Cloud.define('getRecommendedModel', async (request, response) => {
- const classType = request.params.classType
- const classQuery = new Parse.Query(classType)
- const recommendedAppsQuery = new Parse.Query('RecommendedApps')
- const count = await classQuery.count()
- var rand = Math.floor(Math.random() * count)
- classQuery.skip(rand)
- // total recommended items
- classQuery.limit(6)
- recommendedAppsQuery.addDescending('priority')
- var resultList = await classQuery.find()
- const recommendedAppsResult = await recommendedAppsQuery.find()
- //add recommended apps list to resultList
- resultList.unshift(recommendedAppsResult)
- resultList.push(recommendedAppsResult[0])
- const totalPages = 1
- // console.log(`totalPages: ${totalPages} `)
- return { totalPages, resultList }
- })
- /**
- * Strings params:
- * @var classType
- * @var tabTag
- * @var sortTag
- * @var skipCount
- * @var mcVersion
- *
- * add Header Item Object
- * resultList.push('Try these apps:')
- *
- */
- Parse.Cloud.define('getRecommendedModelv2', async (request, response) => {
- // from client
- const classType = request.params.classType
- const classQuery = new Parse.Query(classType)
- const count = await classQuery.count()
- var rand = Math.floor(Math.random() * count)
- classQuery.skip(rand)
- // total recommended items
- classQuery.limit(6)
- const recommendedAppsQuery = new Parse.Query('RecommendedApps')
- recommendedAppsQuery.addDescending('priority')
- const [ resultList, recommendedAppsResult] = await Promise.all([
- classQuery.find(),
- recommendedAppsQuery.find()
- ])
- //add recommended apps list to resultList
- resultList.unshift(recommendedAppsResult)
- resultList.push(recommendedAppsResult[0])
- const totalPages = 1
- // console.log(`totalPages: ${totalPages} `)
- return { totalPages, resultList }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement