Skip to content

Commit

Permalink
Renaming survey->survey_last_updated to survey_last_imported
Browse files Browse the repository at this point in the history
  • Loading branch information
sten committed Sep 6, 2022
1 parent f43bb31 commit 17041a7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ SURVEY {
num id
num surveyhero_id
string name
datetime survey_last_updated
datetime survey_last_imported
}
SURVEY_QUESTIONS {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion database/migrations/create_surveyhero_tables.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/Services/SurveyResponseImportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
}
}
Expand Down

0 comments on commit 17041a7

Please sign in to comment.