Verified Commit 9036f208 authored by David Beniamine's avatar David Beniamine
Browse files

Merge branch '468-duplicate-key-lrl' of gricad-gitlab.univ-grenoble-alpes.fr:labnbook/labnbook

parents f15564d6 24035175
......@@ -8,10 +8,6 @@ use Illuminate\Support\Facades\Log;
class Helper{
/**
* Last modification of a LD in a report : user & timestamp
*
......@@ -475,4 +471,22 @@ EOJS;
}
}
}
/**
* Runs a function in a DB transaction and return it's return value on success
* @return mixed
* @throws \Exception
*/
public static function transaction($fct)
{
DB::beginTransaction();
$out = $fct();
try {
DB::commit();
} catch (\Exception $e) {
DB::rollBack();
throw $e;
}
return $out;
}
}
......@@ -186,10 +186,13 @@ EOSQL
*/
private static function groupUserMissions($user)
{
$all = array_merge(
self::getUserMissionsWithoutTeam($user), // before the other one, so that team may be auto-created
self::getUserMissionsWithTeam($user)
);
$all = \App\Helper::transaction(function () use ($user) {
return array_merge(
self::getUserMissionsWithoutTeam($user), // before the other one, so that team may be auto-created
self::getUserMissionsWithTeam($user)
);
});
usort($all, function ($a, $b) {
return strcmp($a->mission->code, $b->mission->code);
});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment