@@ 235-257 (lines=23) @@ | ||
232 | * |
|
233 | * @return array |
|
234 | */ |
|
235 | private function getAllOverviews() |
|
236 | { |
|
237 | $configRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig'); |
|
238 | $overviewRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsOverview'); |
|
239 | $segmentRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsSegment'); |
|
240 | $configs = $configRepository->findAll(); |
|
241 | ||
242 | foreach ($configs as $config) { |
|
243 | // add overviews if none exist yet |
|
244 | if (\count($config->getOverviews()) == 0) { |
|
245 | $overviewRepository->addOverviews($config); |
|
246 | } |
|
247 | ||
248 | // init all the segments for this config |
|
249 | $segments = $config->getSegments(); |
|
250 | foreach ($segments as $segment) { |
|
251 | $segmentRepository->initSegment($segment); |
|
252 | } |
|
253 | } |
|
254 | ||
255 | // get all overviews |
|
256 | return $overviewRepository->findAll(); |
|
257 | } |
|
258 | ||
259 | /** |
|
260 | * update the overviews |
@@ 162-181 (lines=20) @@ | ||
159 | * |
|
160 | * @return array |
|
161 | */ |
|
162 | private function generateAllOverviews() |
|
163 | { |
|
164 | $configRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig'); |
|
165 | $overviewRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsOverview'); |
|
166 | $segmentRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsSegment'); |
|
167 | $configs = $configRepository->findAll(); |
|
168 | ||
169 | foreach ($configs as $config) { |
|
170 | // add overviews if none exist yet |
|
171 | if (!\count($configRepository->findDefaultOverviews($config))) { |
|
172 | $overviewRepository->addOverviews($config); |
|
173 | } |
|
174 | ||
175 | // init all the segments for this config |
|
176 | $segments = $config->getSegments(); |
|
177 | foreach ($segments as $segment) { |
|
178 | $segmentRepository->initSegment($segment); |
|
179 | } |
|
180 | } |
|
181 | } |
|
182 | } |
|
183 |