sync
Laurent 9 months ago
parent 7f54e6910b
commit ca6a50229f
  1. 18
      sync/migrations/0004_modellog_count.py
  2. 4
      sync/models/model_log.py
  3. 4
      sync/views.py

@ -0,0 +1,18 @@
# Generated by Django 5.1 on 2025-02-05 14:32
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('sync', '0003_modellog_device_id'),
]
operations = [
migrations.AddField(
model_name='modellog',
name='count',
field=models.IntegerField(default=0),
),
]

@ -20,6 +20,7 @@ class ModelLog(models.Model):
model_name = models.CharField(max_length=50) model_name = models.CharField(max_length=50)
store_id = models.CharField(max_length=200, blank=True, null=True) store_id = models.CharField(max_length=200, blank=True, null=True)
device_id = models.CharField(max_length=200, blank=True, null=True) device_id = models.CharField(max_length=200, blank=True, null=True)
count = models.IntegerField(default=0)
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
# Round microseconds to milliseconds (3 decimals to match Swift precision) # Round microseconds to milliseconds (3 decimals to match Swift precision)
@ -27,3 +28,6 @@ class ModelLog(models.Model):
microseconds = round(self.date.microsecond, -3) # Round to nearest thousand microseconds = round(self.date.microsecond, -3) # Round to nearest thousand
self.date = self.date.replace(microsecond=microseconds) self.date = self.date.replace(microsecond=microseconds)
super().save(*args, **kwargs) super().save(*args, **kwargs)
def retrieved(self):
self.count += 1

@ -202,6 +202,10 @@ class SynchronizationApi(HierarchyApiView):
last_log_date = None last_log_date = None
for log in logs: for log in logs:
log.retrieved()
log.save()
# print(f'log date = {log.date}') # print(f'log date = {log.date}')
last_log_date = log.date last_log_date = log.date
try: try:

Loading…
Cancel
Save