mirror of
https://github.com/makeplane/plane.git
synced 2026-02-24 20:20:49 +01:00
dev: github comments and links for the imported issues
This commit is contained in:
@@ -302,16 +302,17 @@ def label_sync(data):
|
||||
existing_label = Label.objects.filter(
|
||||
project_id=data.get("project_id"),
|
||||
workspace_id=data.get("workspace_id"),
|
||||
name__iexact=data.get("data"),
|
||||
name__iexact=data.get("name"),
|
||||
external_id=data.get("external_id", None),
|
||||
external_source=data.get("external_source"),
|
||||
)
|
||||
|
||||
if not existing_label.exists() and data.get("data"):
|
||||
if not existing_label.exists() and data.get("name"):
|
||||
Label.objects.create(
|
||||
project_id=data.get("project_id"),
|
||||
workspace_id=data.get("workspace_id"),
|
||||
name=data.get("name"),
|
||||
color=data.get("color"),
|
||||
created_by_id=data.get("created_by"),
|
||||
external_id=data.get("external_id", None),
|
||||
external_source=data.get("external_source"),
|
||||
@@ -555,14 +556,13 @@ def issue_sync(data):
|
||||
bulk_issue_labels = bulk_issue_labels + [
|
||||
IssueLabel(
|
||||
issue=issue,
|
||||
label_id=get_label_id(name, data).get("id")
|
||||
if get_label_id(name, data)
|
||||
else None,
|
||||
label_id=get_label_id(label.get("name"), data).get("id"),
|
||||
project_id=data.get("project_id"),
|
||||
workspace_id=data.get("workspace_id"),
|
||||
created_by_id=data.get("created_by_id"),
|
||||
)
|
||||
for name in labels_list
|
||||
for label in labels_list
|
||||
if get_label_id(label.get("name"), data).get("id")
|
||||
]
|
||||
|
||||
_ = IssueLabel.objects.bulk_create(
|
||||
@@ -604,11 +604,15 @@ def issue_sync(data):
|
||||
created_by_id=get_user_id(comment.get("created_by")).get("id")
|
||||
if comment.get("created_by_id")
|
||||
else data.get("created_by_id"),
|
||||
external_id=comment.get("external_id"),
|
||||
external_source=comment.get("external_source"),
|
||||
)
|
||||
for comment in comments_list
|
||||
]
|
||||
_ = IssueComment.objects.bulk_create(
|
||||
bulk_issue_comments, batch_size=100
|
||||
)
|
||||
|
||||
_ = IssueComment.objects.bulk_create(bulk_issue_comments, batch_size=100)
|
||||
|
||||
|
||||
@shared_task(queue="segway_tasks")
|
||||
|
||||
@@ -22,8 +22,6 @@ class BaseModel(AuditModel):
|
||||
user = get_current_user()
|
||||
|
||||
if user is None or user.is_anonymous:
|
||||
self.created_by = None
|
||||
self.updated_by = None
|
||||
super(BaseModel, self).save(*args, **kwargs)
|
||||
else:
|
||||
# Check if the model is being created or updated
|
||||
|
||||
@@ -1,73 +1,73 @@
|
||||
import axios from 'axios'
|
||||
import axios from "axios";
|
||||
|
||||
async function* pageThroughIssues(endpoint:any , auth:any) {
|
||||
async function* makeRequest(_endpoint:any) {
|
||||
const response = await axios({
|
||||
url: _endpoint,
|
||||
method: 'get',
|
||||
auth: auth
|
||||
})
|
||||
async function* pageThroughIssues(endpoint: string, auth: any) {
|
||||
async function* makeRequest(_endpoint: string): AsyncGenerator<any> {
|
||||
const response = await axios({
|
||||
url: _endpoint,
|
||||
method: "get",
|
||||
auth: auth,
|
||||
});
|
||||
|
||||
if (response.status !== 200) {
|
||||
throw new Error(await response.statusText)
|
||||
}
|
||||
|
||||
const page = await response.data
|
||||
|
||||
yield page
|
||||
|
||||
if (page.issues.length) {
|
||||
let url = `${endpoint}&startAt=${page.startAt + 100}`
|
||||
yield* makeRequest(url)
|
||||
}
|
||||
if (response.status !== 200) {
|
||||
throw new Error(await response.statusText);
|
||||
}
|
||||
|
||||
yield* makeRequest(endpoint)
|
||||
}
|
||||
const page = await response.data;
|
||||
|
||||
export async function* loadIssues(url:any, auth :any) {
|
||||
const endpoint = url
|
||||
const result = pageThroughIssues(endpoint, auth)
|
||||
yield page;
|
||||
|
||||
for await (const page of result) {
|
||||
for (let issue of page.issues) {
|
||||
yield issue
|
||||
}
|
||||
if (page.issues.length) {
|
||||
const url: string = `${endpoint}&startAt=${page.startAt + 100}`;
|
||||
yield* makeRequest(url);
|
||||
}
|
||||
}
|
||||
|
||||
yield* makeRequest(endpoint);
|
||||
}
|
||||
|
||||
async function* pageThroughComments(endpoint:any, auth :any) {
|
||||
async function* makeRequest(_endpoint) {
|
||||
const response = await axios({
|
||||
url: _endpoint,
|
||||
method: 'get',
|
||||
auth: auth
|
||||
})
|
||||
export async function* loadIssues(url: any, auth: any) {
|
||||
const endpoint = url;
|
||||
const result = pageThroughIssues(endpoint, auth);
|
||||
|
||||
if (response.status !== 200) {
|
||||
throw new Error(await response.statusText)
|
||||
}
|
||||
for await (const page of result) {
|
||||
for (const issue of page.issues) {
|
||||
yield issue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const page = await response.data
|
||||
async function* pageThroughComments(endpoint: any, auth: any) {
|
||||
async function* makeRequest(_endpoint: string): AsyncGenerator<any> {
|
||||
const response = await axios({
|
||||
url: _endpoint,
|
||||
method: "get",
|
||||
auth: auth,
|
||||
});
|
||||
|
||||
yield page
|
||||
|
||||
if (page.comments.length) {
|
||||
let url = `${endpoint}&startAt=${page.startAt + 100}`
|
||||
yield* makeRequest(url)
|
||||
}
|
||||
if (response.status !== 200) {
|
||||
throw new Error(await response.statusText);
|
||||
}
|
||||
|
||||
yield* makeRequest(endpoint)
|
||||
}
|
||||
const page = await response.data;
|
||||
|
||||
export async function* loadComments(url :any, auth :any) {
|
||||
const endpoint = url
|
||||
const result = pageThroughComments(endpoint, auth)
|
||||
yield page;
|
||||
|
||||
for await (const page of result) {
|
||||
for (let comment of page.comments) {
|
||||
yield comment
|
||||
}
|
||||
if (page.comments.length) {
|
||||
const url: string = `${endpoint}&startAt=${page.startAt + 100}`;
|
||||
yield* makeRequest(url);
|
||||
}
|
||||
}
|
||||
|
||||
yield* makeRequest(endpoint);
|
||||
}
|
||||
|
||||
export async function* loadComments(url: any, auth: any) {
|
||||
const endpoint = url;
|
||||
const result = pageThroughComments(endpoint, auth);
|
||||
|
||||
for await (const page of result) {
|
||||
for (const comment of page.comments) {
|
||||
yield comment;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user