-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add search field on the main page #62
- Loading branch information
1 parent
7ee9694
commit 461f91a
Showing
8 changed files
with
2,635 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,3 +45,4 @@ upgrade | |
*.cache | ||
|
||
webroot/js/idp_select/DiscoFeed\.json | ||
webroot/search_list.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace App\Command; | ||
|
||
use Cake\Command\Command; | ||
use Cake\Console\Arguments; | ||
use Cake\Console\ConsoleIo; | ||
use Cake\I18n\FrozenTime; | ||
|
||
/* This file should be run on build to create the JSON file for the seach bar | ||
As well it should be run automatically on regular basis */ | ||
|
||
class GenSearchListCommand extends Command | ||
{ | ||
public function execute(Arguments $args, ConsoleIo $io) | ||
{ | ||
$this->loadModel('DhcrCore.Courses'); | ||
$this->loadModel('Logentries'); | ||
|
||
$io->out('~~~ Started: Generate Search List ~~~'); | ||
|
||
$courses = $this->Courses->find('all', [ | ||
'contain' => ['Institutions'], | ||
'order' => ['Courses.name' => 'asc'] | ||
])->where( | ||
[ | ||
'active' => 1, | ||
'deleted' => 0, | ||
'Courses.updated >' => new FrozenTime('-489 Days'), | ||
'approved' => 1 | ||
] | ||
); | ||
$searchList = []; | ||
foreach ($courses as $course) { | ||
$searchList[] = trim($course->name) . ' - ' . trim($course->institution->name); | ||
} | ||
|
||
$file = fopen('webroot/search_list.json', 'w'); | ||
fwrite($file, json_encode($searchList)); | ||
fclose($file); | ||
|
||
$this->Logentries->createLogEntry( | ||
'10', | ||
'586', | ||
basename(__FILE__, '.php'), | ||
'Generated Search List.', | ||
'Total Courses: ' . sizeof($searchList) | ||
); | ||
|
||
$io->out('Total courses: ' . sizeof($searchList)); | ||
$io->out('~~~ Finished: Generate Search List ~~~'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
|
||
### ENV ### | ||
|
||
CAKE_PATH='/app' | ||
export PATH="/app/.heroku/php/bin:${PATH}" | ||
|
||
### CAKE COMMANDS ### | ||
|
||
bin/cake gen_search_list 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.