@@ 222-244 (lines=23) @@ | ||
219 | * |
|
220 | * @return array |
|
221 | */ |
|
222 | private function getAllOverviews() |
|
223 | { |
|
224 | $configRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig'); |
|
225 | $overviewRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsOverview'); |
|
226 | $segmentRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsSegment'); |
|
227 | $configs = $configRepository->findAll(); |
|
228 | ||
229 | foreach ($configs as $config) { |
|
230 | // add overviews if none exist yet |
|
231 | if (count($config->getOverviews()) == 0) { |
|
232 | $overviewRepository->addOverviews($config); |
|
233 | } |
|
234 | ||
235 | // init all the segments for this config |
|
236 | $segments = $config->getSegments(); |
|
237 | foreach ($segments as $segment) { |
|
238 | $segmentRepository->initSegment($segment); |
|
239 | } |
|
240 | } |
|
241 | ||
242 | // get all overviews |
|
243 | return $overviewRepository->findAll(); |
|
244 | } |
|
245 | ||
246 | /** |
|
247 | * update the overviews |
@@ 159-178 (lines=20) @@ | ||
156 | * |
|
157 | * @return array |
|
158 | */ |
|
159 | private function generateAllOverviews() |
|
160 | { |
|
161 | $configRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig'); |
|
162 | $overviewRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsOverview'); |
|
163 | $segmentRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsSegment'); |
|
164 | $configs = $configRepository->findAll(); |
|
165 | ||
166 | foreach ($configs as $config) { |
|
167 | // add overviews if none exist yet |
|
168 | if (!count($configRepository->findDefaultOverviews($config))) { |
|
169 | $overviewRepository->addOverviews($config); |
|
170 | } |
|
171 | ||
172 | // init all the segments for this config |
|
173 | $segments = $config->getSegments(); |
|
174 | foreach ($segments as $segment) { |
|
175 | $segmentRepository->initSegment($segment); |
|
176 | } |
|
177 | } |
|
178 | } |
|
179 | } |
|
180 |