feat: add "new" tag if first load of the match

This commit is contained in:
Valentin Kaelin 2020-04-01 14:14:03 +02:00
parent 1f7261f0ed
commit a573a7411e
2 changed files with 8 additions and 5 deletions

View file

@ -7,6 +7,11 @@
class="match relative bg-blue-800 text-white text-base cursor-pointer hover:shadow-xl" class="match relative bg-blue-800 text-white text-base cursor-pointer hover:shadow-xl"
> >
<div class="relative flex flex-wrap px-5 py-3"> <div class="relative flex flex-wrap px-5 py-3">
<div
v-if="data.newMatch"
class="new-match absolute right-0 top-0 px-2 text-xxs rounded-full"
style="margin: 0.35rem 0.35rem 0 0; background-color: rgba(99,179,237, .2);"
>New</div>
<div class="first w-4/12 text-left"> <div class="first w-4/12 text-left">
<div> <div>
<div <div

View file

@ -102,10 +102,8 @@ class MatchService {
for (let i = 0; i < gameIds.length; ++i) { for (let i = 0; i < gameIds.length; ++i) {
const matchSaved = await summonerDB.matches().where({ gameId: gameIds[i] }).first() const matchSaved = await summonerDB.matches().where({ gameId: gameIds[i] }).first()
if (matchSaved) { if (matchSaved) {
console.log('match in mongodb')
matchesDetails.push(matchSaved) matchesDetails.push(matchSaved)
} else { } else {
console.log('match to get from api')
matchesToGetFromRiot.push(gameIds[i]) matchesToGetFromRiot.push(gameIds[i])
} }
} }
@ -122,13 +120,13 @@ class MatchService {
await BasicMatchTransformer.transform(matchesFromApi, ctx) await BasicMatchTransformer.transform(matchesFromApi, ctx)
Logger.transport('file').info(matchesFromApi) Logger.transport('file').info(matchesFromApi)
matchesDetails = [...matchesDetails, ...matchesFromApi]
/* Save all matches from Riot Api in db */ /* Save all matches from Riot Api in db */
for (const match of matchesFromApi) { for (const match of matchesFromApi) {
await summonerDB.matches().create(match) await summonerDB.matches().create(match)
console.log('match saved') match.newMatch = true
} }
console.log('matches saved in db')
matchesDetails = [...matchesDetails, ...matchesFromApi]
} }
/* Sort matches */ /* Sort matches */