diff --git a/seeds/contact.js b/seeds/contact.js index b1fd7b6..a2c52ea 100644 --- a/seeds/contact.js +++ b/seeds/contact.js @@ -27,6 +27,7 @@ const seedDB = async () => { try { const { ASPIRE_API_CLIENT_ID, ASPIRE_TOKEN } = process.env; + //Route pullung specific data points from ASPIRE API const apiUrl = `https://cloud-api.youraspire.com/Contacts?%24select=ContactID%2CCompanyName%2CContactTypeName%2CFirstName%2CLastName%2CEmail%2CMobilePhone`; const headers = { 'Authorization': `Bearer ${ASPIRE_TOKEN}`, @@ -38,8 +39,7 @@ const seedDB = async () => { //save to database before going to client // therefore logic to have databse filter logic beofre going to client - // await contacts.save(); - // Save each work ticket visit to the database + for (const contactPerson of contactArray) { const contact = new Contact({ ContactID: contactPerson.ContactID, diff --git a/seeds/opportunity.js b/seeds/opportunity.js index 4d97d1e..0f56a69 100644 --- a/seeds/opportunity.js +++ b/seeds/opportunity.js @@ -27,6 +27,7 @@ const seedDB = async () => { try { const { ASPIRE_API_CLIENT_ID, ASPIRE_TOKEN } = process.env; + //Route pullung specific data points from ASPIRE API const apiUrl = `https://cloud-api.youraspire.com/Opportunities?%24select=OpportunityID%2CPropertyID%2COpportunityStatusName%2CBranchName&%24filter=OpportunityStatusName%20eq%20%27won%27`; const headers = { 'Authorization': `Bearer ${ASPIRE_TOKEN}`, @@ -38,8 +39,8 @@ const seedDB = async () => { //save to database before going to client // therefore logic to have databse filter logic beofre going to client - // await contacts.save(); - // Save each work ticket visit to the database + + for (const wonOpportunity of opportunityArray) { const opportunity = new Opportunity({ OpportunityID: wonOpportunity.OpportunityID, diff --git a/seeds/property.js b/seeds/property.js index 45fdc8c..98cdb4a 100644 --- a/seeds/property.js +++ b/seeds/property.js @@ -26,6 +26,7 @@ const seedDB = async () => { try { const { ASPIRE_API_CLIENT_ID, ASPIRE_TOKEN } = process.env; + //Route pullung specific data points from ASPIRE API const apiUrl = `https://cloud-api.youraspire.com/Properties?%24select=PropertyID%2CBranchName%2CPropertyStatusName%2CPropertyAddressLine1%2CPropertyAddressLine2%2CPropertyAddressCity%2CPropertyAddressStateProvinceCode%2CPropertyAddressZipCode`; const headers = { 'Authorization': `Bearer ${ASPIRE_TOKEN}`, @@ -37,8 +38,7 @@ const seedDB = async () => { //save to database before going to client // therefore logic to have databse filter logic beofre going to client - // await contacts.save(); - // Save each work ticket visit to the database + for (const propertyData of propertyArray) { const property = new Property({ PropertyID: propertyData.PropertyID, diff --git a/seeds/propertyContact.js b/seeds/propertyContact.js index 716442d..87cc3a3 100644 --- a/seeds/propertyContact.js +++ b/seeds/propertyContact.js @@ -26,6 +26,7 @@ const seedDB = async () => { try { const { ASPIRE_API_CLIENT_ID, ASPIRE_TOKEN } = process.env; + //Route pullung specific data points from ASPIRE API const apiUrl = `https://cloud-api.youraspire.com/PropertyContacts?%24select=PropertyID%2CContactID%2CContactName%2CCompanyName`; const headers = { 'Authorization': `Bearer ${ASPIRE_TOKEN}`, @@ -37,8 +38,7 @@ const seedDB = async () => { //save to database before going to client // therefore logic to have databse filter logic beofre going to client - // await contacts.save(); - // Save each work ticket visit to the database + for (const propertyContactData of propertyArray) { const property = new PropertyContact({ PropertyID: propertyContactData.PropertyID, diff --git a/seeds/workticketseed.js b/seeds/workticketseed.js index e3c759f..cc13757 100644 --- a/seeds/workticketseed.js +++ b/seeds/workticketseed.js @@ -27,6 +27,7 @@ const seedDB = async () => { try { const { ASPIRE_API_CLIENT_ID, ASPIRE_TOKEN, ASPIRE_REFRESH_TOKEN } = process.env; + //Route pullung specific data points from ASPIRE API const apiUrl = `https://cloud-api.youraspire.com/WorkTickets?%24select=OpportunityID%2CPrice%2CWorkTicketID%2CBranchName%2CWorkTicketStatusName%2CScheduledStartDate&%24filter=WorkTicketStatusName%20eq%20%27Open%27`; const headers = { 'Authorization': `Bearer ${ASPIRE_TOKEN}`, @@ -38,8 +39,7 @@ const seedDB = async () => { //save to database before going to client // therefore logic to have databse filter logic beofre going to client - // await worktickets.save(); - // Save each work ticket to the database + for (const workticket of workticketArray) { const ticket = new WorkTickets({ WorkTicketID: workticket.WorkTicketID, diff --git a/seeds/index.js b/seeds/workticketvisit.js similarity index 95% rename from seeds/index.js rename to seeds/workticketvisit.js index 18c5ccf..7944071 100644 --- a/seeds/index.js +++ b/seeds/workticketvisit.js @@ -27,6 +27,7 @@ await WorkTicketVisits.deleteMany({}); try { const { ASPIRE_API_CLIENT_ID, ASPIRE_TOKEN } = process.env; + //Route pullung specific data points from ASPIRE API const apiUrl = `https://cloud-api.youraspire.com/WorkTicketVisits?%24select=WorkTicketVisitID%2CWorkTicketID%2CRouteName%2CScheduledDate&%24filter=ScheduledDate%20gt%202024-01-29`; const headers = { 'Authorization': `Bearer ${ASPIRE_TOKEN}`, @@ -38,8 +39,7 @@ await WorkTicketVisits.deleteMany({}); //save to database before going to client // therefore logic to have databse filter logic beofre going to client - // await workticketvisits.save(); - // Save each work ticket visit to the database + for (const workticketvisit of workticketvisitsArray) { const visit = new WorkTicketVisits({ WorkTicketVisitID: workticketvisit.WorkTicketVisitID,