@@ 19-32 (lines=14) @@ | ||
16 | /** |
|
17 | * {@inheritdoc} |
|
18 | */ |
|
19 | public function userAdventureCompletedSteps(UserInterface $user, AdventureInterface $adventure) |
|
20 | { |
|
21 | $qb = $this->getEntityManager()->createQueryBuilder(); |
|
22 | $qb->select('s') |
|
23 | ->from('GameBundle:AdventureStep', 's') |
|
24 | ->leftJoin('s.completions', 'sc') |
|
25 | ->where('sc.user = :user')->setParameter(':user', $user) |
|
26 | ->andWhere('s.adventure = :adventure')->setParameter(':adventure', $adventure) |
|
27 | ->andWhere('sc.pending = 0'); |
|
28 | ||
29 | $queryResult = $qb->getQuery()->getResult(); |
|
30 | ||
31 | return $queryResult; |
|
32 | } |
|
33 | ||
34 | /** |
|
35 | * {@inheritdoc} |
|
@@ 37-50 (lines=14) @@ | ||
34 | /** |
|
35 | * {@inheritdoc} |
|
36 | */ |
|
37 | public function userAdventureClaimedSteps(UserInterface $user, AdventureInterface $adventure) |
|
38 | { |
|
39 | $qb = $this->getEntityManager()->createQueryBuilder(); |
|
40 | $qb->select('s') |
|
41 | ->from('GameBundle:AdventureStep', 's') |
|
42 | ->leftJoin('s.completions', 'sc') |
|
43 | ->where('sc.user = :user')->setParameter(':user', $user) |
|
44 | ->andWhere('s.adventure = :adventure')->setParameter(':adventure', $adventure) |
|
45 | ->andWhere('sc.pending = 1'); |
|
46 | ||
47 | $queryResult = $qb->getQuery()->getResult(); |
|
48 | ||
49 | return $queryResult; |
|
50 | } |
|
51 | ||
52 | /** |
|
53 | * {@inheritdoc} |
|
@@ 55-69 (lines=15) @@ | ||
52 | /** |
|
53 | * {@inheritdoc} |
|
54 | */ |
|
55 | public function userCompletedSteps(UserInterface $user) |
|
56 | { |
|
57 | $qb = $this->getEntityManager()->createQueryBuilder(); |
|
58 | $qb->select('a as adventure, COUNT(sc) as completions') |
|
59 | ->from('GameBundle:Adventure', 'a') |
|
60 | ->leftJoin('a.steps', 's') |
|
61 | ->leftJoin('s.completions', 'sc') |
|
62 | ->where('sc.user = :user')->setParameter(':user', $user) |
|
63 | ->andWhere('sc.pending = 0') |
|
64 | ->groupBy('s.adventure'); |
|
65 | ||
66 | $queryResult = $qb->getQuery()->getResult(); |
|
67 | ||
68 | return $queryResult; |
|
69 | } |
|
70 | } |
|
71 |