liquid_feedback_frontend
changeset 1362:f6c0681aad68
Added generation of sequential number
author | bsw |
---|---|
date | Mon Aug 06 14:12:03 2018 +0200 (2018-08-06) |
parents | 324e01ab8ecf |
children | 4664e021473f |
files | app/main/registration_admin/_action/update_verification.lua |
line diff
1.1 --- a/app/main/registration_admin/_action/update_verification.lua Mon Aug 06 14:00:45 2018 +0200 1.2 +++ b/app/main/registration_admin/_action/update_verification.lua Mon Aug 06 14:12:03 2018 +0200 1.3 @@ -32,6 +32,19 @@ 1.4 value = string.gsub(value, "%s+", " ") 1.5 elseif field.name == "sequential_number" then 1.6 value = old_verification_data.sequential_number 1.7 + if not value then 1.8 + local last_sequential_number = 0 1.9 + db:query('LOCK TABLE "verification" IN SHARE ROW EXCLUSIVE MODE') 1.10 + local max_record = Verification:new_selector() 1.11 + :reset_fields() 1.12 + :add_field("max((verification_data->>'sequential_number')::int8)") 1.13 + :optional_object_mode() 1.14 + :exec() 1.15 + if max_record then 1.16 + last_sequential_number = max_record.verification_data.sequential_number 1.17 + end 1.18 + value = last_sequential_number + 1 1.19 + end 1.20 end 1.21 verification.verification_data[field.name] = value 1.22 end