Skip to content

Commit 3882607

Browse files
committed
[] minor cleanup
1 parent 7cc591e commit 3882607

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

src/AppBundle/Controller/BaseController.php

+15-13
Original file line numberDiff line numberDiff line change
@@ -134,32 +134,32 @@ public function getAllSocial($code = null, $type = null, $subType = null, $field
134134
* @param array $terms
135135
* @return array
136136
*/
137-
public function getSocialDql($vars) {
137+
public function getSocialDql($terms) {
138138
$query = $this->getDoctrine()->getManager()
139139
->createQueryBuilder()
140140
->select('p')
141141
->from('AppBundle:SocialMedia', 'p');
142142

143-
if ($vars['code']) {
144-
$query->where(sprintf("p.code = '%s'", $vars['code']));
143+
if ($terms['code']) {
144+
$query->where(sprintf("p.code = '%s'", $terms['code']));
145145
}
146146

147-
if ($vars['type']) {
148-
$query->andwhere(sprintf("p.type = '%s'", $vars['type']));
147+
if ($terms['type']) {
148+
$query->andwhere(sprintf("p.type = '%s'", $terms['type']));
149149
}
150150

151-
if ($vars['subType']) {
152-
$query->andwhere(sprintf("p.subType = '%s'", $vars['subType']));
151+
if ($terms['subType']) {
152+
$query->andwhere(sprintf("p.subType = '%s'", $terms['subType']));
153153
}
154154

155-
if ($vars['recent']) {
156-
$recentString = date('Y-m-d H:i:s', $vars['recent']);
155+
if ($terms['recent']) {
156+
$recentString = date('Y-m-d H:i:s', $terms['recent']);
157157
$query->andWhere(sprintf("p.postTime > '%s'", $recentString));
158158
}
159159

160-
$query->setFirstResult($vars['offset'])
161-
->setMaxresults($vars['limit'])
162-
->orderBy(sprintf("p.%s", $vars['orderBy']), $vars['direction']);
160+
$query->setFirstResult($terms['offset'])
161+
->setMaxresults($terms['limit'])
162+
->orderBy(sprintf("p.%s", $terms['orderBy']), $terms['direction']);
163163

164164
$socialMedia = $query->getQuery()->getResult();
165165

@@ -176,9 +176,11 @@ public function getSocialDql($vars) {
176176
public function getSelectSocial($socialMedia, $fields) {
177177
$fields = str_replace(' ', '', $fields);
178178
$terms = explode(',', $fields);
179+
$out = [];
179180

180181
foreach ($socialMedia as $social) {
181182
$data = $social->getPostData();
183+
182184
$temp = [
183185
'code' => $social->getCode(),
184186
'type' => $social->getType(),
@@ -188,7 +190,7 @@ public function getSelectSocial($socialMedia, $fields) {
188190

189191
foreach ($terms as $field) {
190192

191-
if ($field == 'time') {
193+
if ($field == 'time' || $field == 'date') {
192194
if ($temp['sub_type'] != 'E') {
193195
$temp['post_' . $field] = isset($data['posted']) ? $data['posted'] : null;
194196

src/AppBundle/Service/PopulationService.php

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public function getPopulation($partyCode) {
4646

4747
/**
4848
* Retrieves population stats from api.population.io and saves to a json file
49+
* @return null
4950
*/
5051
public function getPopulationData() {
5152
$current = $this->checkLocalData();

0 commit comments

Comments
 (0)