-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
creates a model to store jira cached data
Signed-off-by: Conrado Costa <[email protected]>
- Loading branch information
1 parent
b3e7df3
commit 39af4ba
Showing
4 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Generated by Django 3.2.20 on 2023-10-24 15:22 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import uuid | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('osidb', '0100_fix_affectcvss'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Task', | ||
fields=[ | ||
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), | ||
('jira_key', models.CharField(max_length=60)), | ||
('jira_group_key', models.CharField(blank=True, max_length=60)), | ||
('team_id', models.CharField(blank=True, max_length=8)), | ||
('owner', models.CharField(blank=True, max_length=60)), | ||
('status', models.CharField(choices=[('New', 'New'), ('Refinement', 'Refinement'), ('To Do', 'To Do'), ('In Progress', 'In Progress'), ('Review', 'Review'), ('Closed', 'Closed')], default='New', max_length=11)), | ||
('resolution', models.CharField(blank=True, choices=[('', 'None'), ('Done', 'Done'), ("Won't Do", 'Wont Do'), ('Cannot Reproduce', 'Cannot Reproduce'), ("Can't Do", 'Cant Do'), ('Duplicate', 'Duplicate'), ('Not a Bug', 'Not A Bug'), ('Done-Errata', 'Done Errata'), ('MirrorOrphan', 'Mirror Orphan'), ('Obsolete', 'Obsolete'), ('Test Pending', 'Test Pending'), ('Fixed', 'Fixed'), ('Duplicate Ticket', 'Duplicate Ticket')], max_length=16)), | ||
('flaw', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='task', to='osidb.flaw')), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import uuid | ||
|
||
from django.db import models | ||
|
||
from osidb.mixins import NullStrFieldsMixin | ||
from osidb.models import Flaw | ||
|
||
|
||
class JiraCustomFields(models.TextChoices): | ||
EPIC_KEY = "customfield_12311140" | ||
TEAM = "customfield_12313240" | ||
|
||
|
||
class JiraStatus(models.TextChoices): | ||
""" | ||
list of allowable status for tasks in Jira | ||
""" | ||
|
||
NEW = "New" | ||
REFINEMENT = "Refinement" | ||
TO_DO = "To Do" | ||
IN_PROGRESS = "In Progress" | ||
REVIEW = "Review" | ||
CLOSED = "Closed" | ||
|
||
|
||
class JiraResolution(models.TextChoices): | ||
""" | ||
list of allowable resolution for tasks in Jira | ||
""" | ||
|
||
NONE = "" | ||
DONE = "Done" | ||
WONT_DO = "Won't Do" | ||
CANNOT_REPRODUCE = "Cannot Reproduce" | ||
CANT_DO = "Can't Do" | ||
DUPLICATE = "Duplicate" | ||
NOT_A_BUG = "Not a Bug" | ||
DONE_ERRATA = "Done-Errata" | ||
MIRROR_ORPHAN = "MirrorOrphan" | ||
OBSOLETE = "Obsolete" | ||
TEST_PENDING = "Test Pending" | ||
FIXED = "Fixed" | ||
DUPLICATE_TICKET = "Duplicate Ticket" | ||
|
||
|
||
class Task(NullStrFieldsMixin): | ||
""" | ||
Data cached from Jira tasks | ||
""" | ||
|
||
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) | ||
jira_key = models.CharField(max_length=60) | ||
jira_group_key = models.CharField(max_length=60, blank=True) | ||
team_id = models.CharField(max_length=8, blank=True) | ||
owner = models.CharField(max_length=60, blank=True) | ||
status = models.CharField( | ||
choices=JiraStatus.choices, max_length=11, default=JiraStatus.NEW | ||
) | ||
resolution = models.CharField( | ||
choices=JiraResolution.choices, max_length=16, blank=True | ||
) | ||
flaw = models.OneToOneField(Flaw, on_delete=models.CASCADE, related_name="task") | ||
|
||
def update_in_memory(self, issue): | ||
"""Deserializes a jira issue into task model""" | ||
fields = issue["fields"] | ||
self.jira_key = issue["key"] | ||
self.team_id = ( | ||
fields[JiraCustomFields.TEAM]["id"] if fields[JiraCustomFields.TEAM] else "" | ||
) | ||
self.owner = fields["assignee"]["name"] if fields["assignee"] else "" | ||
self.status = fields["status"]["name"] | ||
self.resolution = fields["resolution"]["name"] if fields["resolution"] else "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters