• testtesttestpanorama_fish_eye
    19 posts
    10 years ago
  • rafalplens
    10 years ago

    It would fare much better as Django app, and what when you have thousands of threads? Loading them all into memory won't fly.

  • testtesttestpanorama_fish_eye
    19 posts
    10 years ago

    I couldn't make it otherwise.

  • rafalplens
    10 years ago

    Its very simple actually. Make directory caled "misagositemaps", put __init__.py in it. Put directory into it, name it management. Put __init__.py in it. Finally inside that dir make commands directory. There make empty __init__.py and non-empty makesitemap.py.

    Writing manage.py commands is documented here. Here are example commands defined by Django, and here is command Misago uses to prune forums of old threads.

    For memory-safe iteration over threads, this command imports misago.models.Forum model and runs following:

    for forum in Forum.objects.iterator():
        for thread in forum.thread_set.all().iterator():
            # Thiss wont load all threads to memory and won't crash when you have many threads.
    

    Other issue I've spotted is that it includes private threads, reports as well as threads made in private forums in sitemap. However I admit that in lack of real documentation for 0.5 APIs, its going to be tricky to get it done "right" from nothing.

    So for starters add extra query to pull out lft and rght fields of forum with special="root". Then run second query pulling out ID's on forums that have lft greater than root's one and rght smaller than root's one. Those ID's will belong to forums.

  • avipanorama_fish_eye
    24 posts
    10 years ago

    ^that code snippet looks so beautiful

Search
  • Enter search query (at least 3 characters).

Your options