Default lastUpdated to created; extra error messaging

This commit is contained in:
Robbie Antenesse 2019-05-21 18:54:19 -06:00
parent 1369fb0fdb
commit 6aef828f42
4 changed files with 17 additions and 5 deletions

View File

@ -49,7 +49,7 @@ export const DEFAULT_DICTIONARY = {
isComplete: false,
isPublic: false,
},
lastUpdated: null,
lastUpdated: getTimestampInSeconds(),
createdOn: getTimestampInSeconds(),
version: MIGRATE_VERSION,
};

View File

@ -91,7 +91,7 @@ VALUES ($new_id, ?, ?, ?, ?)";
'name' => $result['name'],
'specification' => $result['specification'],
'description' => $result['description'],
'partsOfSpeech' => $partsOfSpeech,
'partsOfSpeech' => explode(',', $partsOfSpeech),
'details' => array(
'phonology' => array(
'consonants' => $result['consonants'] !== '' ? explode(' ', $result['consonants']) : array(),
@ -118,7 +118,7 @@ VALUES ($new_id, ?, ?, ?, ?)";
'isComplete' => $result['is_complete'] === '1' ? true : false,
'isPublic' => $result['is_public'] === '1' ? true : false,
),
'lastUpdated' => is_null($result['last_updated']) ? null : $result['last_updated'],
'lastUpdated' => is_null($result['last_updated']) ? $results['created_on'] : $result['last_updated'],
'createdOn' => $result['created_on'],
);
}

View File

@ -194,7 +194,13 @@ VALUES (?, ?, ?, ?, ?)';
if ($user_data !== false) {
$user = $user_data->id;
$dictionary = $user_data->dictionary;
return $this->dictionary->setDetails($user, $dictionary, $dictionary_details);
$details_updated = $this->dictionary->setDetails($user, $dictionary, $dictionary_details);
if ($details_updated === true) {
return true;
}
return array(
'error' => $details_updated,
);
}
return false;
}

View File

@ -222,13 +222,19 @@ switch ($action) {
if ($token !== false && isset($request['details'])) {
$user = new User();
$update_details_success = $user->updateCurrentDictionaryDetails($token, $request['details']);
if ($update_details_success !== false) {
if ($update_details_success === true) {
return Response::json(array(
// 'data' => 'Updated successfully',
'data' => $update_details_success,
'error' => false,
), 200);
}
if (isset($update_details_success['error'])) {
return Response::json(array(
'data' => $update_details_success['error'],
'error' => true,
), 500);
}
return Response::json(array(
'data' => 'Could not set dictionary: invalid token',
'error' => true,