Skip to content

Commit

Permalink
feat: added last_updated field for conflict conciliation
Browse files Browse the repository at this point in the history
  • Loading branch information
corp-0 committed Nov 11, 2023
1 parent 49b5429 commit c74fdaf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/persistence/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Meta:
"data",
)

read_only_fields = ("id",)
read_only_fields = ("id", "last_updated")


class UpdateCharacterSerializer(serializers.ModelSerializer):
Expand All @@ -33,7 +33,7 @@ class Meta:
"data",
)

read_only_fields = ("id", "account")
read_only_fields = ("id", "account", "last_updated")


class OtherSerializer(serializers.ModelSerializer):
Expand Down
18 changes: 18 additions & 0 deletions src/persistence/migrations/0002_character_last_updated.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.22 on 2023-11-11 22:53

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('persistence', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='character',
name='last_updated',
field=models.DateTimeField(auto_now=True, help_text='When was this character last updated? Useful for conciliation with the local cache of a character.'),
),
]
5 changes: 5 additions & 0 deletions src/persistence/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class Character(models.Model):
)
"""The character data."""

last_updated = models.DateTimeField(
auto_now=True,
help_text="When was this character last updated? Useful for conciliation with the local cache of a character.",
)

def __str__(self):
return f"{self.account.unique_identifier}'s character"

Expand Down

0 comments on commit c74fdaf

Please sign in to comment.