Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: record issue completed at date when the issues are moved to completed group #262

Merged
merged 1 commit into from
Feb 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions apiserver/plane/db/models/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.conf import settings
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils import timezone

# Module imports
from . import ProjectBaseModel
Expand Down Expand Up @@ -58,6 +59,7 @@ class Issue(ProjectBaseModel):
"db.Label", blank=True, related_name="labels", through="IssueLabel"
)
sort_order = models.FloatField(default=65535)
completed_at = models.DateTimeField(null=True)

class Meta:
verbose_name = "Issue"
Expand Down Expand Up @@ -86,7 +88,22 @@ def save(self, *args, **kwargs):
)
except ImportError:
pass
else:
try:
from plane.db.models import State

# Get the completed states of the project
completed_states = State.objects.filter(
group="completed", project=self.project
).values_list("pk", flat=True)
# Check if the current issue state and completed state id are same
if self.state.id in completed_states:
self.completed_at = timezone.now()
else:
self.completed_at = None

except ImportError:
pass
# Strip the html tags using html parser
self.description_stripped = (
None
Expand Down