Skip to content

Commit

Permalink
Merge pull request #21 from suraj-webkul/data-transfer
Browse files Browse the repository at this point in the history
data transfer version of master
  • Loading branch information
devansh-webkul authored Sep 17, 2024
2 parents 772c0e5 + 4e67391 commit b2d94ac
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/.vuepress/version-configs/master.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ module.exports = [
['advanced/render-event', 'View Render Event'],
['advanced/security-practice', 'Best Security Practices'],
['advanced/sendgrid-inbound-parse-webhook', ' Email Integration via SendGrid Inbound Parse Webhook'],
['advanced/data-transfer', 'Data Transfer'],
])
},
{
Expand Down
81 changes: 81 additions & 0 deletions docs/master/advanced/data-transfer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
[[TOC]]

### Introduction

The **Data Transfer Module** allows you to import large amounts of data from CSV files into your application, with support for leads, products, and persons entities. This module leverages Laravel's queue feature for efficient handling of large datasets, ensuring seamless imports even in high-volume scenarios. Additionally, it includes comprehensive validation and error-handling strategies to provide flexibility in dealing with data integrity.

### Features

- **Queue and Non-Queue Based Import**: Supports importing via Laravel queues for background processing or direct imports for smaller datasets(Without Queue/Sync).
- **CSV Data Validation**: Validate CSV data before importing to ensure data integrity.
- **Validation Strategies**: Choose between different strategies to handle data errors (`Stop on Error`, `Skip Errors`).
- **CSV Delimiter Customization**: Support for different CSV delimiters.
- **Allowed Errors**: Configure the number of allowable errors before the process fails.
- **CRUD Actions**: Supports Create, Update, and Delete operations.

### Usage

#### Importing Data

The module can import data for **Leads**, **Products**, and **Persons** entities from CSV files. You can run the import with or without Laravel's queue feature, depending on your dataset size.

##### Import without Queue

If you prefer to import data without utilizing a queue system, you can achieve this by turning off the queue processing functionality.

##### Import with Queue

If you prefer to import data utilizing a queue system, you can achieve this by turning on the queue processing functionality.

### Validation

Before importing the CSV data, the module validates the records based on the rules defined for each entity. There are two validation strategies you can choose from:

#### Validation Strategies

1. **Stop on Errors**: This strategy will halt the import process when an error is encountered.
2. **Skip Errors**: This strategy skips the rows with errors and continues importing the valid data.

#### CSV Delimiter

The default delimiter is a comma (`,`). If your CSV uses a different delimiter, you can specify it during the import:

### Error Handling

You can configure the number of allowable errors before the process fails. If the error threshold is met, the import will be terminated and shows to display.
Errors during the import process are logged, and a detailed report is generated, showing which rows failed and why.

### CRUD Actions

The module supports three main actions during the import process:

1. **Create**: Add new records.
2. **Update**: Update existing records if they match based on the identifier.
3. **Delete**: Remove records based on the provided data.

- **Create**:
If records do not exist, new records will be created.

- **Update**:
If records exist, they will be updated.

- **Delete**:
If records exist, they will be deleted, Before importing. If the data does not exist, a validation error will be displayed.

### Edit Import Data

Before finalizing the import, you can review and edit the data. The system allows you to preview the imported data and make corrections if needed.

### Queue Configuration

If you are using queues for import, make sure your Laravel queue worker is running:

```bash
php artisan queue:work
```

You can adjust the queue settings in the `config/queue.php` file if needed.

### Conclusion

The **Data Transfer Module** provides a robust solution for importing large datasets into your Krayin application, with flexible options for validation, error handling, and queue-based processing. Whether you're importing millions of records or just a few, this module simplifies the process while ensuring data integrity and flexibility.

0 comments on commit b2d94ac

Please sign in to comment.