diff options
| author | Shadify <boomkin1234@hotmail.com> | 2017-12-01 08:51:24 +0100 | 
|---|---|---|
| committer | Shadify <boomkin1234@hotmail.com> | 2017-12-01 08:51:24 +0100 | 
| commit | 0f5659465584b5ef9fcbec26ea695fe3f1af9012 (patch) | |
| tree | 55daf5da3719e115050bf2f43f4590f07aeb71cf | |
| parent | 491eb42cd125b76f96d4f906c3822202d55395a1 (diff) | |
Sorted all data
| -rw-r--r-- | app/Resources/views/default/index.html.twig | 1 | ||||
| -rw-r--r-- | src/AppBundle/Controller/AllDataController.php | 9 | 
2 files changed, 9 insertions, 1 deletions
| diff --git a/app/Resources/views/default/index.html.twig b/app/Resources/views/default/index.html.twig index 684393d..7882c26 100644 --- a/app/Resources/views/default/index.html.twig +++ b/app/Resources/views/default/index.html.twig @@ -18,6 +18,7 @@          </table>      </div>      <a href="/AllDataReadings">All Data Page</a> +      <p id="aq">{{ Aqi }}</p>      <img src="https://www.ourair.org/wp-content/uploads/AQItable.gif">  {% endblock %} diff --git a/src/AppBundle/Controller/AllDataController.php b/src/AppBundle/Controller/AllDataController.php index 18a30a1..78b4752 100644 --- a/src/AppBundle/Controller/AllDataController.php +++ b/src/AppBundle/Controller/AllDataController.php @@ -5,11 +5,13 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;  use Symfony\Component\HttpFoundation\Response;  use Symfony\Bundle\FrameworkBundle\Controller\Controller; +  class AllDataController extends Controller  {      /**       * @Route("/AllDataReadings", name="AllData")       */ +      public function GetAllData()      {          // Get cURL resource @@ -23,6 +25,12 @@ class AllDataController extends Controller          curl_close($curl);          $data = json_decode($resp, true); + + +        usort($data, function($a,$b){ +            return $a['TimeStamp'] - $b['TimeStamp']; +        }); +          foreach($data as $index => $item)          {              $data[$index]['TimeStamp'] = gmdate("l jS \of F Y h:i:s A", $item['TimeStamp']); @@ -30,7 +38,6 @@ class AllDataController extends Controller          $parametersToTwig = array("data" => $data); -          return $this->render('default/AllDataPage.html.twig',$parametersToTwig); |