Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/replace street maintenance app with maintenance app #386

Open
wants to merge 30 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4eeb501
Copied street maintenance model
juuso-j Sep 17, 2024
6b8cf19
Add maintenance to installed apps
juuso-j Sep 17, 2024
8bf546b
Delete as move to maintenace application
juuso-j Sep 17, 2024
7818d81
Fix import
juuso-j Sep 17, 2024
14e1c53
Delete, moved to maintenance app
juuso-j Sep 17, 2024
2a8ae44
Copy tests from street_maintenance app
juuso-j Sep 17, 2024
f61b526
Delete, moved to maintenance applicaiton
juuso-j Sep 18, 2024
1534e76
Delete, moved to maintenance app
juuso-j Sep 18, 2024
f10ca1c
Change street_maintenance to maintenance in DOC_ENDPOINTS
juuso-j Sep 18, 2024
1ff9f2a
Add tests from street_maintenance application
juuso-j Sep 18, 2024
8a6f9e2
Add __init__.py
juuso-j Sep 18, 2024
bd1d664
Add __init__.py
juuso-j Sep 18, 2024
9e4f796
Add tasks.py from street_maintenance application
juuso-j Sep 18, 2024
d52b36e
Add maintenance AppConfig
juuso-j Sep 18, 2024
1f34e1d
Delete all street_maintenance application tables
juuso-j Sep 18, 2024
27ba44b
Add constants.py from street_maintenance
juuso-j Sep 18, 2024
6111a72
Add models from street_maintenance application
juuso-j Sep 18, 2024
fec6ada
Add API from street_maintenace application
juuso-j Sep 18, 2024
0e261ba
Add admin from street_maintenance
juuso-j Sep 18, 2024
e59ba1b
Add street_maintenance urls for backward compatibility
juuso-j Sep 18, 2024
136d5fd
Add maintenance urls
juuso-j Sep 18, 2024
658c34a
Replace street_maintenance logger settings with maintenance
juuso-j Sep 18, 2024
875ba9e
Add README from street_maintenance
juuso-j Sep 18, 2024
76eb781
Add utils.py from street_maintenance applicaiton
juuso-j Sep 18, 2024
177ad0e
Add management commands from street_maintenance application
juuso-j Sep 18, 2024
c728fec
Add specifications
juuso-j Sep 18, 2024
b6d615b
Delete, as moved to maintenance application
juuso-j Sep 18, 2024
a75d5ba
Fix maintenance urls prefix
juuso-j Sep 19, 2024
6b15e4a
Change STREET_MAINTENANCE_LOG_LEVEL to MAINTENANCE_LOG_LEVEL
juuso-j Oct 1, 2024
9ace48f
Fix comment
juuso-j Oct 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions street_maintenance/README.md → maintenance/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Street Maintenance history
# Maintenance history

Django app for importing and serving street maintenance data.
Django app for importing, processing and serving maintenance data.

## Importer
## Street maintenance history
### Importer
Name:
import_street_maintenance_history

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion street_maintenance/admin.py → maintenance/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.contrib import admin

from street_maintenance.models import MaintenanceUnit, MaintenanceWork
from maintenance.models import MaintenanceUnit, MaintenanceWork

admin.site.register(MaintenanceWork)
admin.site.register(MaintenanceUnit)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from drf_spectacular.utils import extend_schema_field
from rest_framework import serializers

from street_maintenance.models import GeometryHistory, MaintenanceUnit, MaintenanceWork
from maintenance.models import GeometryHistory, MaintenanceUnit, MaintenanceWork


class GeometryHistorySerializer(serializers.ModelSerializer):
Expand Down
5 changes: 2 additions & 3 deletions street_maintenance/api/urls.py → maintenance/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from . import views

app_name = "street_maintenance"
app_name = "maintenance"

router = routers.DefaultRouter()
router.register("active_events", views.ActiveEventsViewSet, basename="active_events")
Expand All @@ -20,6 +20,5 @@
)

urlpatterns = [
# re_path("^street_maintenance/active_events", )
path("", include(router.urls), name="street_maintenance"),
path("", include(router.urls), name="maintenance"),
]
28 changes: 28 additions & 0 deletions maintenance/api/urls_street_maintenance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
Keep backward compatibility to street_maintenance API.
"""

from django.urls import include, path
from rest_framework import routers

from . import views

app_name = "street_maintenance"

router = routers.DefaultRouter()
router.register("active_events", views.ActiveEventsViewSet, basename="active_events")

router.register(
"maintenance_works", views.MaintenanceWorkViewSet, basename="maintenance_works"
)
router.register(
"maintenance_units", views.MaintenanceUnitViewSet, basename="maintenance_units"
)

router.register(
"geometry_history", views.GeometryHitoryViewSet, basename="geometry_history"
)

urlpatterns = [
path("", include(router.urls), name="street_maintenance"),
]
8 changes: 4 additions & 4 deletions street_maintenance/api/views.py → maintenance/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
from rest_framework.exceptions import ParseError
from rest_framework.pagination import PageNumberPagination

from street_maintenance.api.serializers import (
from maintenance.api.serializers import (
ActiveEventSerializer,
GeometryHistorySerializer,
MaintenanceUnitSerializer,
MaintenanceWorkSerializer,
)
from street_maintenance.management.commands.constants import (
from maintenance.management.commands.constants import (
EVENT_CHOICES,
PROVIDERS,
START_DATE_TIME_FORMAT,
)
from street_maintenance.models import GeometryHistory, MaintenanceUnit, MaintenanceWork
from maintenance.models import GeometryHistory, MaintenanceUnit, MaintenanceWork

EXAMPLE_TIME_FORMAT = "YYYY-MM-DD HH:MM:SS"
EXAMPLE_TIME = "2022-09-18 10:00:00"
Expand Down Expand Up @@ -133,7 +133,7 @@ def list(self, request):
list=extend_schema(
description="MaintananceUnit objets are the entities that creates the MaintenanceWorks. Every MaintenanceWork "
"has a relation to a MaintenanceUnit. The type of the MaintenanceUnit can vary depending on the provider. It "
"can be a machine or a event",
"can be a machine or an event.",
),
)
class MaintenanceUnitViewSet(viewsets.ReadOnlyModelViewSet):
Expand Down
6 changes: 6 additions & 0 deletions maintenance/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class MaintenanceConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "maintenance"
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

from django.core.management import BaseCommand

from street_maintenance.models import GeometryHistory, MaintenanceUnit
from maintenance.models import GeometryHistory, MaintenanceUnit

from .constants import PROVIDERS

logger = logging.getLogger("mobility_data")
logger = logging.getLogger("maintenance")

# Add deprecated provider name 'AUTORI'
PROVIDERS.append("AUTORI")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.core.management import BaseCommand

from street_maintenance.models import MaintenanceUnit, MaintenanceWork
from maintenance.models import MaintenanceUnit, MaintenanceWork

from .constants import (
FETCH_SIZE,
Expand All @@ -23,7 +23,7 @@
precalculate_geometry_history,
)

logger = logging.getLogger("street_maintenance")
logger = logging.getLogger("maintenance")


class Command(BaseCommand):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from django.contrib.gis.geos import LineString, Point
from munigeo.models import AdministrativeDivision, AdministrativeDivisionGeometry

from street_maintenance.models import (
from maintenance.models import (
DEFAULT_SRID,
GeometryHistory,
MaintenanceUnit,
Expand All @@ -34,7 +34,7 @@
YIT,
)

logger = logging.getLogger("street_maintenance")
logger = logging.getLogger("maintenance")
# In seconds
MAX_WORK_LENGTH = 60
VALID_LINESTRING_MAX_POINT_DISTANCE = 0.01
Expand Down
156 changes: 156 additions & 0 deletions maintenance/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# Generated by Django 4.2.15 on 2024-09-17 07:26

import django.contrib.gis.db.models.fields
import django.contrib.postgres.fields
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = []

operations = [
migrations.CreateModel(
name="GeometryHistory",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("timestamp", models.DateTimeField()),
(
"geometry",
django.contrib.gis.db.models.fields.GeometryField(
null=True, srid=4326
),
),
(
"coordinates",
django.contrib.postgres.fields.ArrayField(
base_field=django.contrib.postgres.fields.ArrayField(
base_field=models.FloatField(), size=None
),
default=list,
size=None,
),
),
(
"events",
django.contrib.postgres.fields.ArrayField(
base_field=models.CharField(max_length=64),
default=list,
size=None,
),
),
(
"provider",
models.CharField(
choices=[
("INFRAROAD", "Infraroad"),
("YIT", "YIT"),
("KUNTEC", "Kuntec"),
("DESTIA", "Destia"),
],
max_length=16,
null=True,
),
),
],
options={
"ordering": ["-timestamp"],
},
),
migrations.CreateModel(
name="MaintenanceUnit",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("unit_id", models.CharField(max_length=64, null=True)),
(
"provider",
models.CharField(
choices=[
("INFRAROAD", "Infraroad"),
("YIT", "YIT"),
("KUNTEC", "Kuntec"),
("DESTIA", "Destia"),
],
max_length=16,
null=True,
),
),
(
"names",
django.contrib.postgres.fields.ArrayField(
base_field=models.CharField(max_length=64),
default=list,
size=None,
),
),
],
),
migrations.CreateModel(
name="MaintenanceWork",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"geometry",
django.contrib.gis.db.models.fields.GeometryField(
null=True, srid=4326
),
),
(
"events",
django.contrib.postgres.fields.ArrayField(
base_field=models.CharField(max_length=64),
default=list,
size=None,
),
),
(
"original_event_names",
django.contrib.postgres.fields.ArrayField(
base_field=models.CharField(max_length=64),
default=list,
size=None,
),
),
("timestamp", models.DateTimeField()),
(
"maintenance_unit",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="maintenance_work",
to="maintenance.maintenanceunit",
),
),
],
options={
"ordering": ["-timestamp"],
},
),
]
Empty file.
2 changes: 1 addition & 1 deletion street_maintenance/models.py → maintenance/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.contrib.gis.db import models
from django.contrib.postgres.fields import ArrayField

from street_maintenance.management.commands.constants import PROVIDER_CHOICES
from maintenance.management.commands.constants import PROVIDER_CHOICES

DEFAULT_SRID = 4326

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
swagger: "2.0"

info:
description: "Street maintenance API that serves history data of maintenance works, active events and provides history as generated geometries."
description: "Maintenance API that serves history data of maintenance works, active events and provides history as generated geometries."
version: "1.0.0"
title: "Street Maintenance History"
title: Maintenance History"

schemes:
- "https"
Expand Down
File renamed without changes.
Empty file added maintenance/tests/__init__.py
Empty file.
Loading
Loading