On applique black pour cleaner le code
This commit is contained in:
@@ -21,7 +21,5 @@ def run():
|
||||
if len(Category.objects.all()) <= 1:
|
||||
print("On créée des catégories")
|
||||
for c in categories:
|
||||
cat = Category(
|
||||
name=c[0]
|
||||
)
|
||||
cat = Category(name=c[0])
|
||||
cat.save()
|
||||
|
@@ -1,23 +1,28 @@
|
||||
import json, os
|
||||
import json
|
||||
import os
|
||||
|
||||
from django.contrib.gis.geos import Point
|
||||
|
||||
from agenda_culturel.models import ReferenceLocation
|
||||
|
||||
|
||||
def run():
|
||||
input_file = os.path.dirname(__file__) + os.path.sep + "communes.json"
|
||||
data = []
|
||||
with open(input_file, 'r') as file:
|
||||
with open(input_file, "r") as file:
|
||||
data = json.load(file)
|
||||
|
||||
|
||||
# remove all locations
|
||||
ReferenceLocation.objects.all().delete()
|
||||
|
||||
objs = [ReferenceLocation(location=Point(c["geo_point_2d"]["lon"], c["geo_point_2d"]["lat"]),
|
||||
name=c["com_name"],
|
||||
main=c["main"] if "main" in c else 0,
|
||||
suggested_distance=c["suggested"] if "suggested" in c else None) for c in data]
|
||||
objs = [
|
||||
ReferenceLocation(
|
||||
location=Point(c["geo_point_2d"]["lon"], c["geo_point_2d"]["lat"]),
|
||||
name=c["com_name"],
|
||||
main=c["main"] if "main" in c else 0,
|
||||
suggested_distance=c["suggested"] if "suggested" in c else None,
|
||||
)
|
||||
for c in data
|
||||
]
|
||||
|
||||
objs = ReferenceLocation.objects.bulk_create(objs, ignore_conflicts=True)
|
||||
|
||||
|
||||
|
@@ -1,7 +1,6 @@
|
||||
from django.test import RequestFactory
|
||||
import django.urls
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
from django.http import HttpRequest
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
import cProfile
|
||||
|
||||
# inspiré de https://enix.io/fr/blog/django-performance-profiler/
|
||||
@@ -26,8 +25,8 @@ cProfile.runctx(
|
||||
None,
|
||||
locals(),
|
||||
sort="tottime",
|
||||
filename='logs'
|
||||
filename="logs",
|
||||
)
|
||||
|
||||
# puis visualiser avec
|
||||
# snakeviz src/logs
|
||||
# puis visualiser avec
|
||||
# snakeviz src/logs
|
||||
|
@@ -1,9 +1,10 @@
|
||||
from agenda_culturel.models import RecurrentImport
|
||||
|
||||
|
||||
def run():
|
||||
rimports = RecurrentImport.objects.filter(processor="Facebook events").all()
|
||||
|
||||
for r in rimports:
|
||||
r.downloader = "chromium (pause)"
|
||||
|
||||
|
||||
RecurrentImport.objects.bulk_update(rimports, fields=["downloader"])
|
||||
|
Reference in New Issue
Block a user