improve lua script to not store survey_resultaggregate more than once