{"action":"created","issue":{"url":"https://api.github.com/repos/ManageIQ/manageiq/issues/4581","labels_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/4581/labels{/name}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/4581/comments","events_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/4581/events","html_url":"https://github.com/ManageIQ/manageiq/pull/4581","id":108979134,"number":4581,"title":"Fix Product feature seed through more complete tests","user":{"login":"jrafanie","id":19339,"avatar_url":"https://avatars.githubusercontent.com/u/19339?v=3","gravatar_id":"","url":"https://api.github.com/users/jrafanie","html_url":"https://github.com/jrafanie","followers_url":"https://api.github.com/users/jrafanie/followers","following_url":"https://api.github.com/users/jrafanie/following{/other_user}","gists_url":"https://api.github.com/users/jrafanie/gists{/gist_id}","starred_url":"https://api.github.com/users/jrafanie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrafanie/subscriptions","organizations_url":"https://api.github.com/users/jrafanie/orgs","repos_url":"https://api.github.com/users/jrafanie/repos","events_url":"https://api.github.com/users/jrafanie/events{/privacy}","received_events_url":"https://api.github.com/users/jrafanie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-09-29T23:15:30Z","updated_at":"2015-09-30T16:54:01Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/4581","html_url":"https://github.com/ManageIQ/manageiq/pull/4581","diff_url":"https://github.com/ManageIQ/manageiq/pull/4581.diff","patch_url":"https://github.com/ManageIQ/manageiq/pull/4581.patch"},"body":"We have several duplicated identifiers in the `db/fixtures/miq_product_features.yml` when they must be unique.  The seed method will create on the first instance and update on each subsequent instance and the last one in the file always wins.  Since only the last one survives, I chose to delete these \"all but last duplicates\" cc @h-kataria @dclarizio \r\n\r\nTo get this list, I checked manually, but then decided to write a test so we don't accidentally add duplicates again.\r\n\r\nOnce these duplicates were eliminated, I then enhanced the tests to validate the first seed does only creates, a subsequent seed does not make any changes and eliminated some slowness (11 seconds -> 6 locally).\r\n\r\nFinally, I also removed the unused \"feature\" to seed product features from the non-existing `db/fixtures/miq_product_features` directory.  cc @Fryguy @gtanzillo @dclarizio Please let me know if this was wrong, I can't see this being used."},"comment":{"url":"https://api.github.com/repos/ManageIQ/manageiq/issues/comments/144474417","html_url":"https://github.com/ManageIQ/manageiq/pull/4581#issuecomment-144474417","issue_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/4581","id":144474417,"user":{"login":"jrafanie","id":19339,"avatar_url":"https://avatars.githubusercontent.com/u/19339?v=3","gravatar_id":"","url":"https://api.github.com/users/jrafanie","html_url":"https://github.com/jrafanie","followers_url":"https://api.github.com/users/jrafanie/followers","following_url":"https://api.github.com/users/jrafanie/following{/other_user}","gists_url":"https://api.github.com/users/jrafanie/gists{/gist_id}","starred_url":"https://api.github.com/users/jrafanie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrafanie/subscriptions","organizations_url":"https://api.github.com/users/jrafanie/orgs","repos_url":"https://api.github.com/users/jrafanie/repos","events_url":"https://api.github.com/users/jrafanie/events{/privacy}","received_events_url":"https://api.github.com/users/jrafanie/received_events","type":"User","site_admin":false},"created_at":"2015-09-30T16:54:01Z","updated_at":"2015-09-30T16:54:01Z","body":"> If identifier is meant to be unique...let's put a unique validation on the model. Then you don't need to self-check. Seed will just straight-up fail if there are duplicates.\r\n\r\nIt's already there.  Seed will create or update based on the identifier.  It was looping through each identifier section of the yaml, fetch the row (N+1) matching the record, creating or updating it.\r\n\r\nFor example, tail of a log which no product features + seeding showing that we had duplicate identifiers in the yaml that were first created, then updated:\r\n```\r\n[----] I, [2015-09-30T12:52:04.120682 #32449:3fd8b5460208]  INFO -- : MIQ(MiqProductFeature.seed_from_hash) Creating product feature: Identifier: [ab_group_new], Name: [Add a new Button Group]\r\n[----] I, [2015-09-30T12:52:05.439592 #32449:3fd8b5460208]  INFO -- : MIQ(MiqProductFeature.seed_from_hash) Updating product feature: Identifier: [ab_group_new], Name: [Add Button Group]\r\n```"}}