forked from github/plane
fix: added slug in filename for export issues (#1870)
* chore: file name changed for exported issues * fix: added slug in filename for export issues --------- Co-authored-by: NarayanBavisetti <narayan311@gmail.com>
This commit is contained in:
parent
b554087b1f
commit
72419447ec
@ -48,6 +48,7 @@ class ExportIssuesEndpoint(BaseAPIView):
|
|||||||
project_ids=project_ids,
|
project_ids=project_ids,
|
||||||
token_id=exporter.token,
|
token_id=exporter.token,
|
||||||
multiple=multiple,
|
multiple=multiple,
|
||||||
|
slug=slug,
|
||||||
)
|
)
|
||||||
return Response(
|
return Response(
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,7 @@ import zipfile
|
|||||||
|
|
||||||
# Django imports
|
# Django imports
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
# Third party imports
|
# Third party imports
|
||||||
from celery import shared_task
|
from celery import shared_task
|
||||||
@ -64,7 +65,7 @@ def create_zip_file(files):
|
|||||||
return zip_buffer
|
return zip_buffer
|
||||||
|
|
||||||
|
|
||||||
def upload_to_s3(zip_file, workspace_id, token_id):
|
def upload_to_s3(zip_file, workspace_id, token_id, slug):
|
||||||
s3 = boto3.client(
|
s3 = boto3.client(
|
||||||
"s3",
|
"s3",
|
||||||
region_name="ap-south-1",
|
region_name="ap-south-1",
|
||||||
@ -72,7 +73,7 @@ def upload_to_s3(zip_file, workspace_id, token_id):
|
|||||||
aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY,
|
aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY,
|
||||||
config=Config(signature_version="s3v4"),
|
config=Config(signature_version="s3v4"),
|
||||||
)
|
)
|
||||||
file_name = f"{workspace_id}/issues-{token_id}.zip"
|
file_name = f"{workspace_id}/export-{slug}-{token_id[:6]}-{timezone.now()}.zip"
|
||||||
|
|
||||||
s3.upload_fileobj(
|
s3.upload_fileobj(
|
||||||
zip_file,
|
zip_file,
|
||||||
@ -232,7 +233,7 @@ def generate_xlsx(header, project_id, issues, files):
|
|||||||
|
|
||||||
|
|
||||||
@shared_task
|
@shared_task
|
||||||
def issue_export_task(provider, workspace_id, project_ids, token_id, multiple):
|
def issue_export_task(provider, workspace_id, project_ids, token_id, multiple, slug):
|
||||||
try:
|
try:
|
||||||
exporter_instance = ExporterHistory.objects.get(token=token_id)
|
exporter_instance = ExporterHistory.objects.get(token=token_id)
|
||||||
exporter_instance.status = "processing"
|
exporter_instance.status = "processing"
|
||||||
@ -330,7 +331,7 @@ def issue_export_task(provider, workspace_id, project_ids, token_id, multiple):
|
|||||||
)
|
)
|
||||||
|
|
||||||
zip_buffer = create_zip_file(files)
|
zip_buffer = create_zip_file(files)
|
||||||
upload_to_s3(zip_buffer, workspace_id, token_id)
|
upload_to_s3(zip_buffer, workspace_id, token_id, slug)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
exporter_instance = ExporterHistory.objects.get(token=token_id)
|
exporter_instance = ExporterHistory.objects.get(token=token_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user