Skip to content

Commit

Permalink
Serialize without precursor for metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
schinken committed Dec 25, 2018
1 parent 7b29c72 commit 591048c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Controller/Api/MetricsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function userMetrics($userId, ArticleSerializer $articleSerializer, EntityManage
->andWhere('t.recipientTransaction IS NOT NULL')
->getQuery()
->getOneOrNullResult(Query::HYDRATE_ARRAY);

$incomingTransactions = $this->getUserTransactionBaseQuery($user, $entityManager)
->andWhere('t.senderTransaction IS NOT NULL')
->getQuery()
Expand All @@ -79,7 +79,7 @@ function userMetrics($userId, ArticleSerializer $articleSerializer, EntityManage

'articles' => array_map(function ($article) use ($articleSerializer) {
return [
'article' => $articleSerializer->serialize($article['article']),
'article' => $articleSerializer->serializeWithoutPrecursor($article['article']),
'count' => (int) $article['count'],
'amount' => (int) $article['amount'],
];
Expand Down
13 changes: 13 additions & 0 deletions src/Serializer/ArticleSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,17 @@ function serialize(Article $article): array {
'created' => $article->getCreated()->format('Y-m-d H:i:s')
];
}

function serializeWithoutPrecursor(Article $article): array {
return [
'id' => $article->getId(),
'name' => $article->getName(),
'barcode' => $article->getBarcode(),
'amount' => $article->getAmount(),
'isActive' => $article->isActive(),
'usageCount' => $article->getUsageCount(),
'precursor' => null,
'created' => $article->getCreated()->format('Y-m-d H:i:s')
];
}
}

0 comments on commit 591048c

Please sign in to comment.