-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added click analytics models, logic, and admin
- Loading branch information
Showing
4 changed files
with
295 additions
and
3 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
110 changes: 110 additions & 0 deletions
110
url_shortener/migrations/0003_shortenedurl_use_analytics_clickanalytic.py
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,110 @@ | ||
# Generated by Django 4.2.5 on 2023-10-02 08:20 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("url_shortener", "0002_alter_shortenedurl_url"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="shortenedurl", | ||
name="use_analytics", | ||
field=models.BooleanField( | ||
default=False, | ||
help_text="Collect detailed analytics for this shortened url", | ||
), | ||
), | ||
migrations.CreateModel( | ||
name="ClickAnalytic", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"ip_address", | ||
models.GenericIPAddressField( | ||
help_text="The IP address of the user who clicked the shortened url" | ||
), | ||
), | ||
( | ||
"user_agent", | ||
models.CharField( | ||
blank=True, | ||
help_text="The user agent of the user who clicked the shortened url", | ||
max_length=512, | ||
), | ||
), | ||
( | ||
"platform", | ||
models.CharField( | ||
blank=True, | ||
help_text="The platform of the user who clicked the shortened url (mobile vs. desktop)", | ||
max_length=128, | ||
), | ||
), | ||
( | ||
"operating_system", | ||
models.CharField( | ||
blank=True, | ||
help_text="The operating system of the user who clicked the shortened url", | ||
max_length=128, | ||
), | ||
), | ||
( | ||
"device_model", | ||
models.CharField( | ||
blank=True, | ||
help_text="The device model of the user who clicked the shortened url", | ||
max_length=128, | ||
), | ||
), | ||
( | ||
"location_data", | ||
models.JSONField( | ||
blank=True, | ||
help_text="The location data of the user who clicked the shortened url", | ||
), | ||
), | ||
( | ||
"country_name", | ||
models.CharField( | ||
blank=True, | ||
help_text="The country name of the user who clicked the shortened url", | ||
max_length=128, | ||
), | ||
), | ||
( | ||
"city_name", | ||
models.CharField( | ||
blank=True, | ||
help_text="The city name of the user who clicked the shortened url", | ||
max_length=128, | ||
), | ||
), | ||
("created_at", models.DateTimeField(auto_now_add=True)), | ||
( | ||
"shortened_url", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.DO_NOTHING, | ||
related_name="click_analytic", | ||
to="url_shortener.shortenedurl", | ||
), | ||
), | ||
], | ||
options={ | ||
"verbose_name": "Click Analytic", | ||
"ordering": ("-created_at",), | ||
"get_latest_by": "created_at", | ||
}, | ||
), | ||
] |
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
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