Spaces:
Runtime error
Runtime error
File size: 859 Bytes
9c63b5a d747060 9c63b5a ea09d29 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import { fetchPortfolio } from './propertyware.service';
import PwPortfolio from '../../models/pwPortfolio';
import { logger } from '../../utils/logger';
export const syncPortfolioDataService = async (): Promise<string> => {
try {
const portfolioData = await fetchPortfolio();
const portfolioResponseData = portfolioData.map((portfolio: { id: any; name: any; }) => ({
pw_id: portfolio.id,
name: portfolio.name,
}));
await PwPortfolio.bulkCreate(portfolioResponseData, {
updateOnDuplicate: ['name'],
});
logger.info("Portfolio data synced successfully");
return "Portfolio data synced successfully";
} catch (error) {
logger.error("Error syncing Portfolio");
logger.error(error);
throw new Error("Error syncing Portfolio");
}
};
|