def touch_cache(request, project_id): response = HttpResponse(mimetype="text/plain") if CACHE_ENABLED: Project.touch_cache(project_id) response.write("Touched cache for project %s\n" % project_id) response.write("CACHE_PREFIX=%s\n" % CACHE_PREFIX) else: response.write("Caching is disabled") return response
def invalidate_cache(sender, instance, **kwargs): from agilito.models import Project ids = [] if isinstance(instance, User): ids = [p.id for p in instance.project_set.all()] elif hasattr(instance, 'project'): ids = [instance.project.id] for id in ids: Project.touch_cache(id)
os.chdir(BACKLOG_ARCHIVE) call('git add .') call('git commit -a -m "%s"' % datetime.date.today().isoformat()) from django.db import connection, transaction cursor = connection.cursor() cursor.execute('delete from agilito_archivedbacklog') id = 0 projects = [] repo = Repo(BACKLOG_ARCHIVE) for commit in repo.revision_history(repo.head()): for mode, name, sha in repo.tree(commit.tree).entries(): m = re.match('([0-9]+)[.]ods$', name) if not m: continue project_id = int(m.group(1)) if not project_id in projects: projects.append(project_id) id += 1 cursor.execute(""" insert into agilito_archivedbacklog (id, stamp, project_id, commit) values (%s, %s, %s, %s)""", (id, datetime.datetime.fromtimestamp(commit.commit_time), project_id, commit.tree)) transaction.commit_unless_managed() for project_id in projects: Project.touch_cache(project_id)