Looks like the above code will generate the new entries  in resource summary table when ever user rated for the resource, it should be override. Can you check this ?