Skip to content

Commit

Permalink
Add more time entries types
Browse files Browse the repository at this point in the history
- Meeting (Internal)
- Testing
- Research
- OPERATION
  • Loading branch information
thenav56 committed Aug 27, 2024
1 parent f643bca commit 226ebb3
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 15 deletions.
71 changes: 71 additions & 0 deletions apps/track/migrations/0017_alter_timeentry_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Generated by Django 4.2.15 on 2024-08-27 11:14

from django.db import migrations, models

TIME_ENTRY_TYPE_MIGRATION = {
1000: 1, # Design
1200: 2, # DevOps
1100: 3, # Development
3100: 4, # Discussion (External)
3000: 5, # Discussion (Internal)
2000: 6, # Documentation
4000: 7, # Meeting (External)
5000: 10, # Project Management
6000: 12, # Testing
}


def migrate_time_entry_data(apps, _):
TimeEntry = apps.get_model("track", "TimeEntry")
qs = TimeEntry.objects.all()

print("Migrating data....")
for existing_type_value, new_type_value in TIME_ENTRY_TYPE_MIGRATION.items():
updated = qs.filter(type=existing_type_value).update(type=new_type_value)
print(f"\t {existing_type_value} -> {new_type_value}: items updated: {updated}")


def revert_migrate_time_entry_data(apps, _):
TimeEntry = apps.get_model("track", "TimeEntry")
qs = TimeEntry.objects.all()

print("Migrating back data....")
for existing_type_value, new_type_value in TIME_ENTRY_TYPE_MIGRATION.items():
updated = qs.filter(type=new_type_value).update(type=existing_type_value)
print(f"\t {new_type_value} -> {existing_type_value}: items updated: {updated}")


class Migration(migrations.Migration):

dependencies = [
("track", "0016_alter_timeentry_type"),
]

operations = [
migrations.AlterField(
model_name="timeentry",
name="type",
field=models.PositiveSmallIntegerField(
blank=True,
choices=[
(6, "Documentation"),
(11, "Research"),
(1, "Design"),
(9, "Operation"),
(10, "Project Management"),
(12, "Testing"),
(3, "Development"),
(2, "DevOps"),
(4, "Discussion (External)"),
(5, "Discussion (Internal)"),
(7, "Meeting (External)"),
(8, "Meeting (Internal)"),
],
null=True,
),
),
migrations.RunPython(
migrate_time_entry_data,
reverse_code=revert_migrate_time_entry_data,
),
]
32 changes: 22 additions & 10 deletions apps/track/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,28 @@ def __str__(self):

class TimeEntry(models.Model):
class Type(models.IntegerChoices):
# Using 4 digit for future ordering support
DESIGN = 1000, _("Design")
DEVELOPMENT = 1100, _("Development")
DEV_OPS = 1200, _("DevOps")
DOCUMENTATION = 2000, _("Documentation")
INTERNAL_DISCUSSION = 3000, _("Internal Discussion")
EXTERNAL_DISCUSSION = 3100, _("External Discussion")
MEETING = 4000, _("Meeting")
PROJECT_MANAGEMENT = 5000, _("Project Management")
QUALITY_ASSURANCE = 6000, _("QA")
# XXX: Custom integer value is used to support sort by label

# For MISC, user will leave it empty
# Generic
DOCUMENTATION = 6, _("Documentation")
RESEARCH = 11, _("Research")
DESIGN = 1, _("Design")
OPERATION = 9, _("Operation")
PROJECT_MANAGEMENT = 10, _("Project Management")
TESTING = 12, _("Testing")

# Development
DEVELOPMENT = 3, _("Development")
DEV_OPS = 2, _("DevOps")

# Communication
# - Discussion
EXTERNAL_DISCUSSION = 4, _("Discussion (External)")
INTERNAL_DISCUSSION = 5, _("Discussion (Internal)")
# - Meeting
EXTERNAL_MEETING = 7, _("Meeting (External)")
INTERNAL_MEETING = 8, _("Meeting (Internal)")

class Status(models.IntegerChoices):
DOING = 1, _("Doing")
Expand Down
13 changes: 8 additions & 5 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -685,15 +685,18 @@ type TimeEntryTypeCountList {
}

enum TimeEntryTypeEnum {
DOCUMENTATION
RESEARCH
DESIGN
OPERATION
PROJECT_MANAGEMENT
TESTING
DEVELOPMENT
DEV_OPS
DOCUMENTATION
INTERNAL_DISCUSSION
EXTERNAL_DISCUSSION
MEETING
PROJECT_MANAGEMENT
QUALITY_ASSURANCE
INTERNAL_DISCUSSION
EXTERNAL_MEETING
INTERNAL_MEETING
}

type TimeEntryTypeMutationResponseType {
Expand Down

0 comments on commit 226ebb3

Please sign in to comment.