magaton / spring-petclinic

A sample Spring-based application
Apache License 2.0
0 stars 0 forks source link

Replace first name and last name with name #3

Open magaton opened 7 months ago

magaton commented 7 months ago

Replace "first name" and "last name" fields with single field "name" for all the users of the system.

Checklist - [X] Modify `src/main/java/org/springframework/samples/petclinic/model/Person.java` ✓ https://github.com/magaton/spring-petclinic/commit/22331e8ede8eb0e80804b5ecbc5e76e2470095b6 [Edit](https://github.com/magaton/spring-petclinic/edit/sweep/replace_first_name_and_last_name_with_na/src/main/java/org/springframework/samples/petclinic/model/Person.java) - [X] Running GitHub Actions for `src/main/java/org/springframework/samples/petclinic/model/Person.java` ✓ [Edit](https://github.com/magaton/spring-petclinic/edit/sweep/replace_first_name_and_last_name_with_na/src/main/java/org/springframework/samples/petclinic/model/Person.java) - [X] Modify `src/main/resources/templates/owners/createOrUpdateOwnerForm.html` ✓ https://github.com/magaton/spring-petclinic/commit/5fb1f14e6c4795501a0ac15401b00a74564efb37 [Edit](https://github.com/magaton/spring-petclinic/edit/sweep/replace_first_name_and_last_name_with_na/src/main/resources/templates/owners/createOrUpdateOwnerForm.html) - [X] Running GitHub Actions for `src/main/resources/templates/owners/createOrUpdateOwnerForm.html` ✓ [Edit](https://github.com/magaton/spring-petclinic/edit/sweep/replace_first_name_and_last_name_with_na/src/main/resources/templates/owners/createOrUpdateOwnerForm.html) - [X] Modify `src/main/resources/templates/pets/createOrUpdateVisitForm.html` ✓ https://github.com/magaton/spring-petclinic/commit/52cb1848c7322fed332274b951e20ca9ef6c1d95 [Edit](https://github.com/magaton/spring-petclinic/edit/sweep/replace_first_name_and_last_name_with_na/src/main/resources/templates/pets/createOrUpdateVisitForm.html) - [X] Running GitHub Actions for `src/main/resources/templates/pets/createOrUpdateVisitForm.html` ✓ [Edit](https://github.com/magaton/spring-petclinic/edit/sweep/replace_first_name_and_last_name_with_na/src/main/resources/templates/pets/createOrUpdateVisitForm.html) - [X] Modify `src/main/resources/db/h2/schema.sql` ✓ https://github.com/magaton/spring-petclinic/commit/a123c7d78a3e06c7f4243bb7faac93ed5c113551 [Edit](https://github.com/magaton/spring-petclinic/edit/sweep/replace_first_name_and_last_name_with_na/src/main/resources/db/h2/schema.sql) - [X] Running GitHub Actions for `src/main/resources/db/h2/schema.sql` ✓ [Edit](https://github.com/magaton/spring-petclinic/edit/sweep/replace_first_name_and_last_name_with_na/src/main/resources/db/h2/schema.sql) - [X] Modify `src/main/resources/db/postgres/data.sql` ✓ https://github.com/magaton/spring-petclinic/commit/964204b4110c17a881c228fb37026405c29f934f [Edit](https://github.com/magaton/spring-petclinic/edit/sweep/replace_first_name_and_last_name_with_na/src/main/resources/db/postgres/data.sql) - [X] Running GitHub Actions for `src/main/resources/db/postgres/data.sql` ✓ [Edit](https://github.com/magaton/spring-petclinic/edit/sweep/replace_first_name_and_last_name_with_na/src/main/resources/db/postgres/data.sql) - [X] Modify `src/main/resources/db/h2/data.sql` ✓ https://github.com/magaton/spring-petclinic/commit/93fe8213faf166d02bfaff935ce33e679aff7d2e [Edit](https://github.com/magaton/spring-petclinic/edit/sweep/replace_first_name_and_last_name_with_na/src/main/resources/db/h2/data.sql) - [X] Running GitHub Actions for `src/main/resources/db/h2/data.sql` ✓ [Edit](https://github.com/magaton/spring-petclinic/edit/sweep/replace_first_name_and_last_name_with_na/src/main/resources/db/h2/data.sql) - [X] Modify `src/main/java/org/springframework/samples/petclinic/owner/Owner.java` ✓ https://github.com/magaton/spring-petclinic/commit/c3009a714d2f73ea7cf50c93ddd0dfcd2020ec06 [Edit](https://github.com/magaton/spring-petclinic/edit/sweep/replace_first_name_and_last_name_with_na/src/main/java/org/springframework/samples/petclinic/owner/Owner.java) - [X] Running GitHub Actions for `src/main/java/org/springframework/samples/petclinic/owner/Owner.java` ✓ [Edit](https://github.com/magaton/spring-petclinic/edit/sweep/replace_first_name_and_last_name_with_na/src/main/java/org/springframework/samples/petclinic/owner/Owner.java)
magaton commented 7 months ago

🚀 Here's the PR! #4

See Sweep's progress at the progress dashboard!
💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: None)

[!TIP] I can email you next time I complete a pull request if you set up your email here!


Actions (click)


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/magaton/spring-petclinic/blob/41a383c6a923d9c2a75ab877f345815d23e83582/src/main/java/org/springframework/samples/petclinic/model/Person.java#L22-L53 https://github.com/magaton/spring-petclinic/blob/41a383c6a923d9c2a75ab877f345815d23e83582/src/main/resources/templates/owners/createOrUpdateOwnerForm.html#L1-L29 https://github.com/magaton/spring-petclinic/blob/41a383c6a923d9c2a75ab877f345815d23e83582/src/main/resources/templates/pets/createOrUpdateVisitForm.html#L1-L60 https://github.com/magaton/spring-petclinic/blob/41a383c6a923d9c2a75ab877f345815d23e83582/src/main/resources/db/postgres/data.sql#L1-L50 https://github.com/magaton/spring-petclinic/blob/41a383c6a923d9c2a75ab877f345815d23e83582/src/main/resources/db/h2/schema.sql#L1-L63

Step 2: ⌨️ Coding

--- 
+++ 
@@ -27,28 +27,16 @@
 @MappedSuperclass
 public class Person extends BaseEntity {

-   @Column(name = "first_name")
+   @Column(name = "name")
    @NotBlank
-   private String firstName;
+   private String name;

-   @Column(name = "last_name")
-   @NotBlank
-   private String lastName;
-
-   public String getFirstName() {
-       return this.firstName;
+   public String getName() {
+       return this.name;
    }

-   public void setFirstName(String firstName) {
-       this.firstName = firstName;
-   }
-
-   public String getLastName() {
-       return this.lastName;
-   }
-
-   public void setLastName(String lastName) {
-       this.lastName = lastName;
+   public void setName(String name) {
+       this.name = name;
    }

 }

Ran GitHub Actions for 22331e8ede8eb0e80804b5ecbc5e76e2470095b6:

--- 
+++ 
@@ -7,9 +7,7 @@
   
- + th:replace="~{fragments/inputField :: input ('Name', 'name', 'text')}" />

  • [X] Running GitHub Actions for src/main/resources/templates/owners/createOrUpdateOwnerForm.htmlEdit
    Check src/main/resources/templates/owners/createOrUpdateOwnerForm.html with contents:

Ran GitHub Actions for 5fb1f14e6c4795501a0ac15401b00a74564efb37:

--- 
+++ 
@@ -24,7 +24,7 @@
         th:text="${#temporals.format(pet.birthDate, 'yyyy-MM-dd')}">
       
       
+        th:text="${owner?.name}">
     
   

  • [X] Running GitHub Actions for src/main/resources/templates/pets/createOrUpdateVisitForm.htmlEdit
    Check src/main/resources/templates/pets/createOrUpdateVisitForm.html with contents:

Ran GitHub Actions for 52cb1848c7322fed332274b951e20ca9ef6c1d95:

--- 
+++ 
@@ -35,13 +35,12 @@

 CREATE TABLE owners (
   id         INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
-  first_name VARCHAR(30),
-  last_name  VARCHAR_IGNORECASE(30),
+  name       VARCHAR(255),
   address    VARCHAR(255),
   city       VARCHAR(80),
   telephone  VARCHAR(20)
 );
-CREATE INDEX owners_last_name ON owners (last_name);
+

 CREATE TABLE pets (
   id         INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,

  • [X] Running GitHub Actions for src/main/resources/db/h2/schema.sqlEdit
    Check src/main/resources/db/h2/schema.sql with contents:

Ran GitHub Actions for a123c7d78a3e06c7f4243bb7faac93ed5c113551:

--- 
+++ 
@@ -22,16 +22,16 @@
 INSERT INTO types (name) SELECT 'bird' WHERE NOT EXISTS (SELECT * FROM specialties WHERE name='bird');
 INSERT INTO types (name) SELECT 'hamster' WHERE NOT EXISTS (SELECT * FROM specialties WHERE name='cat');

-INSERT INTO owners (first_name, last_name, address, city, telephone) SELECT 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023' WHERE NOT EXISTS (SELECT * FROM owners WHERE id=1);
-INSERT INTO owners (first_name, last_name, address, city, telephone) SELECT 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749' WHERE NOT EXISTS (SELECT * FROM owners WHERE id=2);
-INSERT INTO owners (first_name, last_name, address, city, telephone) SELECT 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763' WHERE NOT EXISTS (SELECT * FROM owners WHERE id=3);
-INSERT INTO owners (first_name, last_name, address, city, telephone) SELECT 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198' WHERE NOT EXISTS (SELECT * FROM owners WHERE id=4);
-INSERT INTO owners (first_name, last_name, address, city, telephone) SELECT 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765' WHERE NOT EXISTS (SELECT * FROM owners WHERE id=5);
-INSERT INTO owners (first_name, last_name, address, city, telephone) SELECT 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654' WHERE NOT EXISTS (SELECT * FROM owners WHERE id=6);
-INSERT INTO owners (first_name, last_name, address, city, telephone) SELECT 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387' WHERE NOT EXISTS (SELECT * FROM owners WHERE id=7);
-INSERT INTO owners (first_name, last_name, address, city, telephone) SELECT 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683' WHERE NOT EXISTS (SELECT * FROM owners WHERE id=8);
-INSERT INTO owners (first_name, last_name, address, city, telephone) SELECT 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435' WHERE NOT EXISTS (SELECT * FROM owners WHERE id=9);
-INSERT INTO owners (first_name, last_name, address, city, telephone) SELECT 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487' WHERE NOT EXISTS (SELECT * FROM owners WHERE id=10);
+INSERT INTO owners (name, address, city, telephone) SELECT 'George Franklin', '110 W. Liberty St.', 'Madison', '6085551023' WHERE NOT EXISTS (SELECT * FROM owners WHERE id=1);
+INSERT INTO owners (name, address, city, telephone) SELECT 'Betty Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749' WHERE NOT EXISTS (SELECT * FROM owners WHERE id=2);
+INSERT INTO owners (name, address, city, telephone) SELECT 'Eduardo Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763' WHERE NOT EXISTS (SELECT * FROM owners WHERE id=3);
+INSERT INTO owners (name, address, city, telephone) SELECT 'Harold Davis', '563 Friendly St.', 'Windsor', '6085553198' WHERE NOT EXISTS (SELECT * FROM owners WHERE id=4);
+INSERT INTO owners (name, address, city, telephone) SELECT 'Peter McTavish', '2387 S. Fair Way', 'Madison', '6085552765' WHERE NOT EXISTS (SELECT * FROM owners WHERE id=5);
+INSERT INTO owners (name, address, city, telephone) SELECT 'Jean Coleman', '105 N. Lake St.', 'Monona', '6085552654' WHERE NOT EXISTS (SELECT * FROM owners WHERE id=6);
+INSERT INTO owners (name, address, city, telephone) SELECT 'Jeff Black', '1450 Oak Blvd.', 'Monona', '6085555387' WHERE NOT EXISTS (SELECT * FROM owners WHERE id=7);
+INSERT INTO owners (name, address, city, telephone) SELECT 'Maria Escobito', '345 Maple St.', 'Madison', '6085557683' WHERE NOT EXISTS (SELECT * FROM owners WHERE id=8);
+INSERT INTO owners (name, address, city, telephone) SELECT 'David Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435' WHERE NOT EXISTS (SELECT * FROM owners WHERE id=9);
+INSERT INTO owners (name, address, city, telephone) SELECT 'Carlos Estaban', '2335 Independence La.', 'Waunakee', '6085555487' WHERE NOT EXISTS (SELECT * FROM owners WHERE id=10);

 INSERT INTO pets (name, birth_date, type_id, owner_id) SELECT 'Leo', '2000-09-07', 1, 1 WHERE NOT EXISTS (SELECT * FROM pets WHERE id=1);
 INSERT INTO pets (name, birth_date, type_id, owner_id) SELECT 'Basil', '2002-08-06', 6, 2 WHERE NOT EXISTS (SELECT * FROM pets WHERE id=2);

  • [X] Running GitHub Actions for src/main/resources/db/postgres/data.sqlEdit
    Check src/main/resources/db/postgres/data.sql with contents:

Ran GitHub Actions for 964204b4110c17a881c228fb37026405c29f934f:

--- 
+++ 
@@ -22,16 +22,16 @@
 INSERT INTO types VALUES (default, 'bird');
 INSERT INTO types VALUES (default, 'hamster');

-INSERT INTO owners VALUES (default, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023');
-INSERT INTO owners VALUES (default, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749');
-INSERT INTO owners VALUES (default, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763');
-INSERT INTO owners VALUES (default, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198');
-INSERT INTO owners VALUES (default, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765');
-INSERT INTO owners VALUES (default, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654');
-INSERT INTO owners VALUES (default, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387');
-INSERT INTO owners VALUES (default, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683');
-INSERT INTO owners VALUES (default, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435');
-INSERT INTO owners VALUES (default, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487');
+INSERT INTO owners VALUES (default, 'George Franklin', '110 W. Liberty St.', 'Madison', '6085551023');
+INSERT INTO owners VALUES (default, 'Betty Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749');
+INSERT INTO owners VALUES (default, 'Eduardo Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763');
+INSERT INTO owners VALUES (default, 'Harold Davis', '563 Friendly St.', 'Windsor', '6085553198');
+INSERT INTO owners VALUES (default, 'Peter McTavish', '2387 S. Fair Way', 'Madison', '6085552765');
+INSERT INTO owners VALUES (default, 'Jean Coleman', '105 N. Lake St.', 'Monona', '6085552654');
+INSERT INTO owners VALUES (default, 'Jeff Black', '1450 Oak Blvd.', 'Monona', '6085555387');
+INSERT INTO owners VALUES (default, 'Maria Escobito', '345 Maple St.', 'Madison', '6085557683');
+INSERT INTO owners VALUES (default, 'David Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435');
+INSERT INTO owners VALUES (default, 'Carlos Estaban', '2335 Independence La.', 'Waunakee', '6085555487');

 INSERT INTO pets VALUES (default, 'Leo', '2010-09-07', 1, 1);
 INSERT INTO pets VALUES (default, 'Basil', '2012-08-06', 6, 2);

  • [X] Running GitHub Actions for src/main/resources/db/h2/data.sqlEdit
    Check src/main/resources/db/h2/data.sql with contents:

Ran GitHub Actions for 93fe8213faf166d02bfaff935ce33e679aff7d2e:

--- 
+++ 
@@ -146,8 +146,7 @@
    public String toString() {
        return new ToStringCreator(this).append("id", this.getId())
            .append("new", this.isNew())
-           .append("lastName", this.getLastName())
-           .append("firstName", this.getFirstName())
+           .append("name", this.getName())
            .append("address", this.address)
            .append("city", this.city)
            .append("telephone", this.telephone)

  • [X] Running GitHub Actions for src/main/java/org/springframework/samples/petclinic/owner/Owner.javaEdit
    Check src/main/java/org/springframework/samples/petclinic/owner/Owner.java with contents:

Ran GitHub Actions for c3009a714d2f73ea7cf50c93ddd0dfcd2020ec06:


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/replace_first_name_and_last_name_with_na.


🎉 Latest improvements to Sweep:
  • New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
  • Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
  • Use the GitHub issues extension for creating Sweep issues directly from your editor.

💡 To recreate the pull request edit the issue title or description. Something wrong? Let us know.

This is an automated message generated by Sweep AI.