Skip to content
Permalink
Browse files
Merge branch 'feature/individual-page' of https://github.coventry.ac.…
…uk/5001CEM-1920SEPJAN/soperd into feature/individual-page
  • Loading branch information
byrnec5 committed Dec 1, 2019
2 parents e35fd74 + c4072ed commit 28847aed36fb5716a8e7a5cc4fad14e2854c39c9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
@@ -1,3 +1,4 @@
/* eslint-disable max-statements */
/* eslint-disable max-lines-per-function */
/* eslint-disable complexity */
'use strict'
@@ -12,7 +13,7 @@ const dbctx = new db.SqliteDbContext(path.join(__dirname, '/../app.db'))
request('https://api.steampowered.com/ISteamApps/GetAppList/v2/', async(error, response, body) => {
const allGames = JSON.parse(body)
let i = 1
const gameAmount = 10 //change according to how many games you want to add
const gameAmount = 200 //change according to how many games you want to add
for(i; i<gameAmount; i++) {
const gameid = allGames.applist.apps[i].appid //getting the appID to insert into next URL as a string
gameid.toString()
@@ -53,9 +54,22 @@ request('https://api.steampowered.com/ISteamApps/GetAppList/v2/', async(error, r
'yes',
gameData.header_image,
gameData.screenshots[0].path_thumbnail)
game.categories = gameData.categories
game.categories = []
let category
for(let i=0; i<gameData.genres.length; i++) {
gameData.genres[i].id = -1
gameData.genres[i].name = gameData.genres[i].description
delete gameData.genres[i].description
try{
category = await dbctx.createCategory(gameData.genres[i])
} catch(err) {
category = await dbctx.getCategory(gameData.genres[i].name)
}
game.categories.push(category)
}
game = await dbctx.createGame(game)
const platform = await dbctx.getPlatform(38)
const pltfrm = 38
const platform = await dbctx.getPlatform(pltfrm)
await dbctx.linkGamePlatform(game, platform)
} catch(err) {
throw new Error(`Game: https://store.steampowered.com/api/appdetails/?appids=${gameid} ${err}`)
@@ -15,7 +15,7 @@ game.get('/game:id', async ctx => {
throw new Error('game ID must be a number')
}
const gamedata = await ctx.db.getGame(Number(ctx.params.id))
console.log(gamedata)
//console.log(gamedata)
const reviews = (await ctx.db.getReviewsForGame(Number(gamedata.gameID))).reverse()
const reviewCount = reviews.length
const platforms = gamedata.platforms
@@ -55,7 +55,7 @@ game.get('/allReviews:id', async ctx => {
const comments = []
for (let i = 0; i < reviewCount; i++) {
comments.push(await ctx.db.getCommentsForReview(i))
console.log(comments[i])
//console.log(comments[i])
}
if(gamedata.poster.startsWith('http')) {
gamedata.url = true
@@ -103,7 +103,7 @@ game.post('/postComment', async ctx => {
try {
const body = ctx.request.body
const user = await ctx.db.getUser(ctx.session.userID)
console.log(user)
//console.log(user)
const comment = new Comment(body.gameID, body.reviewID, user.username, 'DD/MM/YYYY', 'XX:YY:ZZ', body.commentText)
await ctx.db.postComment(comment)
ctx.redirect(`/allReviews${body.gameID}`)

0 comments on commit 28847ae

Please sign in to comment.