diff --git a/README.md b/README.md index 78aeaf8..fee329e 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ SURVEY { num id num surveyhero_id string name - datetime survey_last_updated + datetime survey_last_imported } SURVEY_QUESTIONS { @@ -293,14 +293,16 @@ php artisan surveyhero:map - Add more default indices to the migration. - Support more Surveyhero question types. -- Support more converted value data types, e.g. double +- Support more converted value data types, e.g. double. - A command to check the `question_mapping` configuration to validate if: - there are no double field names - there are no double question IDs. - there are no double answer IDs. - the data format for a question time is ok, i.e. are all fields there and are they the right type. - all questions and answers are mapped by doing an API request. -- A command to create a basic question_mapping configuration based on the [Surveyhero Element API](https://developer.surveyhero.com/api/#element-api) +- Export survey responses to CSV and Excel +- Statistics calculator service to quickly query aggregates of responses of questions. +- ~~A command to create a basic question_mapping configuration based on the [Surveyhero Element API](https://developer.surveyhero.com/api/#element-api)~~ - A command to create all surveys in the Surveyhero account. ## Testing diff --git a/database/migrations/create_surveyhero_tables.php.stub b/database/migrations/create_surveyhero_tables.php.stub index 3f50acd..fedc867 100644 --- a/database/migrations/create_surveyhero_tables.php.stub +++ b/database/migrations/create_surveyhero_tables.php.stub @@ -13,7 +13,7 @@ class CreateSurveyheroTables extends Migration $table->bigInteger('surveyhero_id'); $table->string('name'); - $table->datetime('survey_last_updated')->nullable(); + $table->datetime('survey_last_imported')->nullable(); $table->timestamps(); }); diff --git a/src/Models/Survey.php b/src/Models/Survey.php index f64696d..c40db4c 100644 --- a/src/Models/Survey.php +++ b/src/Models/Survey.php @@ -12,7 +12,7 @@ * @property int $id * @property int $surveyhero_id * @property string $name - * @property Carbon|null $survey_last_updated + * @property Carbon|null $survey_last_imported * @property Carbon $created_at * @property Carbon $updated_at * @property Collection $surveyResponses diff --git a/src/Services/SurveyResponseImportService.php b/src/Services/SurveyResponseImportService.php index f1d45fa..51e3d4f 100644 --- a/src/Services/SurveyResponseImportService.php +++ b/src/Services/SurveyResponseImportService.php @@ -84,7 +84,7 @@ public function importSurveyResponse($responseId, Survey $survey, $surveyQuestio //do not import already imported data that is not updated. /* @var SurveyResponse $existingResponseRecord */ $existingResponseRecord = SurveyResponse::where('surveyhero_id', $responseId)->first(); - if ($existingResponseRecord && ($existingResponseRecord->survey_completed || $existingResponseRecord->survey_last_updated->lte($survey->survey_last_updated))) { + if ($existingResponseRecord && ($existingResponseRecord->survey_completed || $existingResponseRecord->survey_last_updated->lte($survey->survey_last_imported))) { return; } @@ -120,8 +120,8 @@ public function importSurveyResponse($responseId, Survey $survey, $surveyQuestio //increase survey last updated timestamp: $responseLastUpdatedOn = $this->client->transformAPITimestamp($responseAnswers->last_updated_on); - if (is_null($survey->survey_last_updated) || $responseLastUpdatedOn->gt($survey->survey_last_updated)) { - $survey->survey_last_updated = $responseLastUpdatedOn; + if (is_null($survey->survey_last_imported) || $responseLastUpdatedOn->gt($survey->survey_last_imported)) { + $survey->survey_last_imported = $responseLastUpdatedOn; } } }