Santhisanduri / O2i

0 stars 0 forks source link

Task Tile #2

Open Santhisanduri opened 1 week ago

Santhisanduri commented 1 week ago

please give me project structure and wmls site contacts wants add in o2i db

codeautopilot[bot] commented 1 week ago

Potential solution

To address the task, we need to make changes to multiple files to ensure that WMLS site contacts are properly added to the O2I database. This involves creating a new table in the database schema, updating the project structure documentation, configuring the database connection, and seeding initial data.

How to implement

1. Update db/schema.sql

We will create a new table named wmls_site_contacts to store the WMLS site contacts.

Code:

-- Create a new table for WMLS site contacts
CREATE TABLE wmls_site_contacts (
    id SERIAL PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    email VARCHAR(255) NOT NULL,
    phone VARCHAR(20),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

2. Update project_structure.md

We will create a detailed project structure document that outlines the directories and files relevant to the project.

Code:

# Project Structure

This document outlines the structure of the project, including directories and files, to help developers understand the organization of the codebase.

## Root Directory
- **README.md**: Project overview and instructions.
- **project_structure.md**: This document.
- **config/**: Configuration files for the project.
- **db/**: Database-related files.
- **src/**: Source code for the application.
- **tests/**: Test files and test-related resources.

## config/
- **database.yml**: Database configuration settings.

## db/
- **schema.sql**: SQL schema for database structure.
- **seed_data.sql**: SQL statements for seeding initial data into the database.

## src/
- **main.py**: Main application entry point.
- **utils/**: Utility functions and helpers.
- **models/**: Data models and ORM classes.
- **controllers/**: Application logic and controllers.

## tests/
- **test_main.py**: Tests for the main application.
- **test_utils/**: Tests for utility functions.
- **test_models/**: Tests for data models.
- **test_controllers/**: Tests for controllers.

## Adding WMLS Site Contacts
To add WMLS site contacts to the O2I database, follow these steps:
1. **Update the Database Schema**: Modify `db/schema.sql` to include a new table or fields for storing WMLS site contacts.
2. **Seed Initial Data**: Add SQL statements in `db/seed_data.sql` to insert WMLS site contacts into the database.
3. **Configure Database**: Ensure `config/database.yml` is set up correctly to accommodate the new data.

3. Update config/database.yml

We will create a proper configuration for the database connection.

Code:

default: &default
  adapter: postgresql
  encoding: unicode
  pool: 5
  username: <%= ENV['DB_USERNAME'] %>
  password: <%= ENV['DB_PASSWORD'] %>
  host: <%= ENV['DB_HOST'] %>
  port: <%= ENV['DB_PORT'] %>

development:
  <<: *default
  database: myapp_development

test:
  <<: *default
  database: myapp_test

production:
  <<: *default
  database: myapp_production
  username: <%= ENV['DB_PROD_USERNAME'] %>
  password: <%= ENV['DB_PROD_PASSWORD'] %>
  host: <%= ENV['DB_PROD_HOST'] %>
  port: <%= ENV['DB_PROD_PORT'] %>

4. Update db/seed_data.sql

We will add SQL statements to insert initial WMLS site contacts into the database.

Code:

-- Insert WMLS site contacts into the wmls_site_contacts table
INSERT INTO wmls_site_contacts (id, name, email, phone, address) VALUES
(1, 'John Doe', 'john.doe@example.com', '123-456-7890', '123 Elm Street'),
(2, 'Jane Smith', 'jane.smith@example.com', '987-654-3210', '456 Oak Avenue'),
(3, 'Alice Johnson', 'alice.johnson@example.com', '555-123-4567', '789 Pine Road');

By following these steps, we ensure that the WMLS site contacts are properly added to the O2I database, and the project structure is well-documented and organized.

Click here to create a Pull Request with the proposed solution

Files used for this task:

Changes on db/schema.sql To address the task for the `db/schema.sql` file, you need to create a new table or add new fields to an existing table to store WMLS site contacts. Here is a practical proposal for modifying the schema: 1. **Create a New Table for WMLS Site Contacts:** - Define a new table named `wmls_site_contacts` with appropriate fields such as `id`, `name`, `email`, `phone`, and any other relevant information. 2. **SQL Schema Definition:** - Write the SQL statements to create this new table. Here is an example of how you can modify the `db/schema.sql` file to include a new table for storing WMLS site contacts: ```sql -- Create a new table for WMLS site contacts CREATE TABLE wmls_site_contacts ( id SERIAL PRIMARY KEY, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, phone VARCHAR(20), created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ); ``` ### Explanation: - `id`: A unique identifier for each contact. - `name`: The name of the contact. - `email`: The email address of the contact. - `phone`: The phone number of the contact. - `created_at`: Timestamp for when the record was created. - `updated_at`: Timestamp for when the record was last updated. This schema provides a basic structure for storing WMLS site contacts in the O2I database. You can adjust the fields and data types as needed based on the specific requirements of your project. If there are no additional requirements or modifications needed for this file, this should be sufficient to fulfill the task.
Changes on project_structure.md To address the task for the `project_structure.md` file, you need to create a detailed project structure document that outlines the directories and files relevant to the project. Here is a concrete proposal for how to structure this document: ### project_structure.md ```markdown # Project Structure This document outlines the structure of the project, including directories and files, to help developers understand the organization of the codebase. ## Root Directory - **README.md**: Project overview and instructions. - **project_structure.md**: This document. - **config/**: Configuration files for the project. - **db/**: Database-related files. - **src/**: Source code for the application. - **tests/**: Test files and test-related resources. ## config/ - **database.yml**: Database configuration settings. ## db/ - **schema.sql**: SQL schema for database structure. - **seed_data.sql**: SQL statements for seeding initial data into the database. ## src/ - **main.py**: Main application entry point. - **utils/**: Utility functions and helpers. - **models/**: Data models and ORM classes. - **controllers/**: Application logic and controllers. ## tests/ - **test_main.py**: Tests for the main application. - **test_utils/**: Tests for utility functions. - **test_models/**: Tests for data models. - **test_controllers/**: Tests for controllers. ## Adding WMLS Site Contacts To add WMLS site contacts to the O2I database, follow these steps: 1. **Update the Database Schema**: Modify `db/schema.sql` to include a new table or fields for storing WMLS site contacts. 2. **Seed Initial Data**: Add SQL statements in `db/seed_data.sql` to insert WMLS site contacts into the database. 3. **Configure Database**: Ensure `config/database.yml` is set up correctly to accommodate the new data. ``` This structure provides a clear and organized overview of the project's directories and files, making it easier for developers to navigate and understand the codebase.
Changes on config/database.yml Since the `config/database.yml` file is currently empty, you need to create a proper configuration for your database. This configuration file is crucial for connecting your application to the database where the WMLS site contacts will be stored. Here's a practical proposal to set up the `config/database.yml` file: 1. **Identify the Database Type**: Determine whether you are using PostgreSQL, MySQL, SQLite, or another database system. 2. **Set Up Environment-Specific Configurations**: Typically, you will have different configurations for development, testing, and production environments. 3. **Include Necessary Credentials**: Ensure that you include the database name, username, password, host, and port. Below is an example configuration for a PostgreSQL database: ```yaml default: &default adapter: postgresql encoding: unicode pool: 5 username: <%= ENV['DB_USERNAME'] %> password: <%= ENV['DB_PASSWORD'] %> host: <%= ENV['DB_HOST'] %> port: <%= ENV['DB_PORT'] %> development: <<: *default database: myapp_development test: <<: *default database: myapp_test production: <<: *default database: myapp_production username: <%= ENV['DB_PROD_USERNAME'] %> password: <%= ENV['DB_PROD_PASSWORD'] %> host: <%= ENV['DB_PROD_HOST'] %> port: <%= ENV['DB_PROD_PORT'] %> ``` ### Steps to Implement: 1. **Create the `config/database.yml` file**: If it doesn't already exist, create the file in the `config` directory. 2. **Add the Configuration**: Copy the above YAML configuration into the file. 3. **Set Environment Variables**: Ensure that the environment variables (`DB_USERNAME`, `DB_PASSWORD`, etc.) are set in your environment or in a `.env` file if you are using a library like `dotenv`. 4. **Test the Configuration**: Run your application and ensure it can connect to the database successfully. By following these steps, you will ensure that your database configuration is correctly set up to accommodate the new WMLS site contacts data.
Changes on db/seed_data.sql To address the task for the `db/seed_data.sql` file, you need to add SQL statements that will insert WMLS site contacts into the O2I database. Here is a practical proposal for how to do this: 1. **Identify the Schema**: Ensure you know the structure of the table where the WMLS site contacts will be stored. This should be defined in `db/schema.sql`. 2. **Create Insert Statements**: Write SQL `INSERT` statements to add the WMLS site contacts data into the appropriate table. ### Example SQL Statements Assuming the table for WMLS site contacts is named `wmls_site_contacts` and has the following columns: `id`, `name`, `email`, `phone`, `address`. ```sql -- Insert WMLS site contacts into the wmls_site_contacts table INSERT INTO wmls_site_contacts (id, name, email, phone, address) VALUES (1, 'John Doe', 'john.doe@example.com', '123-456-7890', '123 Elm Street'), (2, 'Jane Smith', 'jane.smith@example.com', '987-654-3210', '456 Oak Avenue'), (3, 'Alice Johnson', 'alice.johnson@example.com', '555-123-4567', '789 Pine Road'); ``` ### Steps to Implement 1. **Open the `db/seed_data.sql` file**. 2. **Add the SQL `INSERT` statements** as shown in the example above. 3. **Save the file**. ### Final `db/seed_data.sql` File ```sql -- Insert WMLS site contacts into the wmls_site_contacts table INSERT INTO wmls_site_contacts (id, name, email, phone, address) VALUES (1, 'John Doe', 'john.doe@example.com', '123-456-7890', '123 Elm Street'), (2, 'Jane Smith', 'jane.smith@example.com', '987-654-3210', '456 Oak Avenue'), (3, 'Alice Johnson', 'alice.johnson@example.com', '555-123-4567', '789 Pine Road'); ``` This will seed the database with initial WMLS site contacts data. Ensure that the `id` values are unique and follow the schema defined in `db/schema.sql`.
Santhisanduri commented 1 week ago

Found some old convos and stuff, posting some finding soon re: notifications Context: There was work over a year and a half ago to get wmls retired sooner, so questions were brought up on what dependencies still existed with O2I and I was asked this and I mentioned, naturally, notifications. Gathering my thoughts and links, so here we go (edited) :raised_hands::skin-tone-2: 1

5 replies

Umesh Mandadapu Wednesday at 3:34 PM @richly : Thanks, Are you planning to send links or attachments to this message

Richly Chheuy Wednesday at 3:52 PM Since we're talking about Transfer Manager, we'll be looking at the https://gitlab.disney.com/O2I/o2i-transfer-manager-web repo. In particular: https://gitlab.disney.com/O2I/o2i-transfer-manager-web/-/blob/develop/src/main/java/com/disney/spt/receiving/process/step/AbstractSimpleNotificationProcessStep.java https://gitlab.disney.com/O2I/o2i-transfer-manager-web/-/blob/develop/src/main/java/com/disney/spt/receiving/process/step/TransferToTargetNotificationProcessStep.java TransferToTargetNotificationProcessStep extends AbstractSimpleNotificationProcessStep class above. Looking at buildNotificationTask() Notice instantiations of wmls-related classes, e.g. wmlsService . This triggers the lookup to get site info and create the notification email. Probably can refactor the logic here to start and instead do a lookup via local db/data that matches siteId being passed through the workflow (if you're cloning that data from wmls db) protected Task buildNotificationTask() { StorageSite site = wmlsService.getSite(getProcessData().getTargetLocationId()); EmailTemplate template = notificationService.buildEmailTemplate(getConfigurationProperty(EMAIL_TEMPLATE, true));

    Set<NotificationContact> contacts = new HashSet<>();
    contacts.add(new NotificationContact(vendorAndContactService.getSptUserForUsername(getProcessData().getUserName())));
    contacts.add(new NotificationContact(site.getPrimaryContact()));
    contacts.addAll(wmlsService.getSiteNotificationContacts(site)); 
    contacts.addAll(notificationService.emailsToContacts(getProcessData().getAdditionalContacts()));

    Map<String, Object> emailParams = new HashMap<>();
    emailParams.put("targetDesc", wmlsService.getSite(getProcessData().getTargetLocationId()).getDescription());

    SendNotificationForReceivingRequestTask task = buildTask(SendNotificationForReceivingRequestTask.class);
    task.init(getProcessData(), emailParams, contacts, null, null, template);

    return task;
}

Other related: https://gitlab.disney.com/O2I/o2i-wmls-client/-/blob/develop/src/main/java/com/disney/spt/service/wmls/WmlsRestService.java https://gitlab.disney.com/O2I/o2i-wmls-client/-/blob/develop/src/main/java/com/disney/spt/service/wmls/WmlsRestClient.java Snapshot of convo thread from a long while back when asked about this and the stack trace of the error when WMLS db is inaccessible when generating the notification. Can see which lines in source are being executed up until error. (edited) 2 files

Screenshot 2024-09-04 at 3.50.40 PM.png

Screenshot 2023-03-16 at 3.10.28 PM (1).png

3:55 Easier to deal with transfer manager web pipeline since that has been most recently changed, tested.

Richly Chheuy Wednesday at 4:05 PM tl;dr I guess ultimate create your own custom class(es) to instead call local o2i db data. Some examples where some o2i notifs build an email from user_account table I believe, such as for Transfer Manager problem emails. That is taking users who are part of spt_group_membership admin and apply to them to field: https://gitlab.disney.com/O2I/o2i-transfer-manager-web/-/blob/develop/src/main/resources/transfermanager.properties https://gitlab.disney.com/O2I/o2i-transfer-manager-web/-/blob/develop/src/main/java/c[…]/spt/receiving/service/notification/NotificationService.java notification.problem.targetGroup

Notification configuration

used as a flag to disable all email when testing

notification.email.disableEmail = false notification.email.server = sptmailrelay.studio.disney.com notification.email.fromAddress = twds.transmgr@studio.disney.com notification.email.fromName = Disney Transfer Manager notification.email.groupsToCopy = SPT-SoftwareNotifications notification.email.addressesToCopy = notification.email.subjectPrefix = (Dev)

notification.problem.targetGroup = ${admin.group} notification.requestDetail.uri = http://foo.bar.baz/ (edited)

Richly Chheuy Wednesday at 4:34 PM On the zoom call, https://gitlab.disney.com/O2I/o2i-email-service/-/blob/develop/emailapi-web/src/main/java/com/disney/spt/mail/controller/ApiController.java was shown, but no wmls classes are referenced, so I think the o2i-email-service is more of a way to better manage or handle email templating (when emails are being sent out) for various types of notifications (as we have to remember O2I being a beast of an app back in its heyday and different types of emails were sent out depending on the app or workflow). (edited)" please read this chat we have a new project for you guys. As you may have heard, WMLS is moving to Studio to be deprecated. O2i currently has dependencies within WMLS- particularly the table pertaining to the notification step of TM1 transfers wmls_site_contacts & also other tables holding the foreign keys within this. We will need to pull this table into the O2i db & also update the code configurations within the O2i repos. The first step is to clone down the O2i repos & try to locate where this table is in the code

Santhisanduri commented 1 week ago

Found some old convos and stuff, posting some finding soon re: notifications Context: There was work over a year and a half ago to get wmls retired sooner, so questions were brought up on what dependencies still existed with O2I and I was asked this and I mentioned, naturally, notifications. Gathering my thoughts and links, so here we go (edited) 🙌:skin-tone-2: 1

5 replies

Umesh Mandadapu Wednesday at 3:34 PM @richly : Thanks, Are you planning to send links or attachments to this message

Richly Chheuy Wednesday at 3:52 PM Since we're talking about Transfer Manager, we'll be looking at the https://gitlab.disney.com/O2I/o2i-transfer-manager-web repo. In particular: https://gitlab.disney.com/O2I/o2i-transfer-manager-web/-/blob/develop/src/main/java/com/disney/spt/receiving/process/step/AbstractSimpleNotificationProcessStep.java https://gitlab.disney.com/O2I/o2i-transfer-manager-web/-/blob/develop/src/main/java/com/disney/spt/receiving/process/step/TransferToTargetNotificationProcessStep.java TransferToTargetNotificationProcessStep extends AbstractSimpleNotificationProcessStep class above. Looking at buildNotificationTask() Notice instantiations of wmls-related classes, e.g. wmlsService . This triggers the lookup to get site info and create the notification email. Probably can refactor the logic here to start and instead do a lookup via local db/data that matches siteId being passed through the workflow (if you're cloning that data from wmls db) protected Task buildNotificationTask() { StorageSite site = wmlsService.getSite(getProcessData().getTargetLocationId()); EmailTemplate template = notificationService.buildEmailTemplate(getConfigurationProperty(EMAIL_TEMPLATE, true));

Set<NotificationContact> contacts = new HashSet<>();
contacts.add(new NotificationContact(vendorAndContactService.getSptUserForUsername(getProcessData().getUserName())));
contacts.add(new NotificationContact(site.getPrimaryContact()));
contacts.addAll(wmlsService.getSiteNotificationContacts(site)); 
contacts.addAll(notificationService.emailsToContacts(getProcessData().getAdditionalContacts()));

Map<String, Object> emailParams = new HashMap<>();
emailParams.put("targetDesc", wmlsService.getSite(getProcessData().getTargetLocationId()).getDescription());

SendNotificationForReceivingRequestTask task = buildTask(SendNotificationForReceivingRequestTask.class);
task.init(getProcessData(), emailParams, contacts, null, null, template);

return task;

} Other related: https://gitlab.disney.com/O2I/o2i-wmls-client/-/blob/develop/src/main/java/com/disney/spt/service/wmls/WmlsRestService.java https://gitlab.disney.com/O2I/o2i-wmls-client/-/blob/develop/src/main/java/com/disney/spt/service/wmls/WmlsRestClient.java Snapshot of convo thread from a long while back when asked about this and the stack trace of the error when WMLS db is inaccessible when generating the notification. Can see which lines in source are being executed up until error. (edited) 2 files

Screenshot 2024-09-04 at 3.50.40 PM.png

Screenshot 2023-03-16 at 3.10.28 PM (1).png

3:55 Easier to deal with transfer manager web pipeline since that has been most recently changed, tested.

Richly Chheuy Wednesday at 4:05 PM tl;dr I guess ultimate create your own custom class(es) to instead call local o2i db data. Some examples where some o2i notifs build an email from user_account table I believe, such as for Transfer Manager problem emails. That is taking users who are part of spt_group_membership admin and apply to them to field: https://gitlab.disney.com/O2I/o2i-transfer-manager-web/-/blob/develop/src/main/resources/transfermanager.properties https://gitlab.disney.com/O2I/o2i-transfer-manager-web/-/blob/develop/src/main/java/c[…]/spt/receiving/service/notification/NotificationService.java notification.problem.targetGroup

Notification configuration

used as a flag to disable all email when testing

notification.email.disableEmail = false notification.email.server = sptmailrelay.studio.disney.com notification.email.fromAddress = twds.transmgr@studio.disney.com notification.email.fromName = Disney Transfer Manager notification.email.groupsToCopy = SPT-SoftwareNotifications notification.email.addressesToCopy = notification.email.subjectPrefix = (Dev)

notification.problem.targetGroup = ${admin.group} notification.requestDetail.uri = http://foo.bar.baz/ (edited)

Richly Chheuy Wednesday at 4:34 PM On the zoom call, https://gitlab.disney.com/O2I/o2i-email-service/-/blob/develop/emailapi-web/src/main/java/com/disney/spt/mail/controller/ApiController.java was shown, but no wmls classes are referenced, so I think the o2i-email-service is more of a way to better manage or handle email templating (when emails are being sent out) for various types of notifications (as we have to remember O2I being a beast of an app back in its heyday and different types of emails were sent out depending on the app or workflow). (edited)" please read this chat we have a new project for you guys. As you may have heard, WMLS is moving to Studio to be deprecated. O2i currently has dependencies within WMLS- particularly the table pertaining to the notification step of TM1 transfers wmls_site_contacts & also other tables holding the foreign keys within this. We will need to pull this table into the O2i db & also update the code configurations within the O2i repos. The first step is to clone down the O2i repos & try to locate where this table is in the code""