remote jobs

This commit is contained in:
2018-11-21 18:14:56 +03:00
parent 5a8b88b225
commit b013b1213b
5 changed files with 66 additions and 3 deletions

View File

@ -136,6 +136,20 @@ class HhController extends Controller
return $this->redirect(['/hh/hh']);
}
public function actionGetJobsRemote($id)
{
$model = \common\models\Hh::findOne($id);
$jobs = HHService::run()->company($model->hh_id)->getJobs();
$count = 0;
foreach ((array)$jobs as $job) {
if(HhJob::createFromHHRemote($job)){
$count++;
}
}
Yii::$app->session->setFlash('success', "Получено $count новых вакансий");
return $this->redirect(['/hh/hh']);
}
/**
* Finds the Hh model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.

View File

@ -34,12 +34,19 @@ $this->params['breadcrumbs'][] = $this->title;
'class' => 'yii\grid\DataColumn',
'format' => 'raw',
'value' => function ($model) {
return Html::a('Получить вакансии', \yii\helpers\Url::to([
$html = Html::a('Получить все вакансии', \yii\helpers\Url::to([
'/hh/hh/get-jobs',
'id' => $model->id
]), [
'class' => 'btn btn-success'
]);
$html = $html . '<br><br>' . $html = Html::a('Только "удаленная работа"', \yii\helpers\Url::to([
'/hh/hh/get-jobs-remote',
'id' => $model->id
]), [
'class' => 'btn btn-success'
]);
return $html;
},
],

View File

@ -9,7 +9,8 @@ use yii\widgets\DetailView;
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => 'hh.ru', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
//\common\classes\Debug::dd(\common\hhapi\core\service\HHService::run()->company($model->hh_id)->get())
//\common\classes\Debug::prn(\common\hhapi\core\service\HHService::run()->vacancy(28246746)->get());
//\common\classes\Debug::dd(\common\hhapi\core\service\HHService::run()->company($model->hh_id)->getJobs())
?>
<div class="hh-view">