#!/usr/bin/env python

INDEXES = """
django_admin_log:content_type,object_id,action_time
django_admin_log:user,-action_time
__Stat_Kind__:kind_name,-timestamp
prefixes_prefix:length,timestamp
prefixes_prefix:length,-com
prefixes_prefix:length,resume
prefixes_suffix:length,timestamp
prefixes_suffix:length,-com
prefixes_suffix:length,resume
tests_comparison:path,-timestamp
feedback_feedback:page,-submitted
feedback_feedback:page,-points,-submitted
feedback_feedback:-points,-submitted
dns_lookup:-__key__
dns_lookup:com,backwards
domains_domain:-__key__
domains_domain:length,-score
""".split()


for length in range(1, 7):
    for right in range(0, length + 1):
        left = length - right
        minimum = min(left, right)
        maximum = max(left, right)
        if minimum and minimum + maximum > 5:
            continue
        parts = []
        if left:
            parts.append('left%d' % left)
        if right:
            parts.append('right%d' % right)
        parts.append('length')
        parts.append('-score')
        INDEXES.append('domains_domain:' + ','.join(parts))


print 'indexes:'
for index in INDEXES:
    kind, properties = index.split(':')
    print
    print '- kind:', kind
    print '  properties:'
    for property in properties.split(','):
        print '  - name:', property.lstrip('-')
        if property.startswith('-'):
            print '    direction: desc'

print """
# AUTOGENERATED

# This index.yaml is automatically updated whenever the dev_appserver
# detects that a new type of query is run.  If you want to manage the
# index.yaml file manually, remove the above marker line (the line
# saying "# AUTOGENERATED").  If you want to manage some indexes
# manually, move them above the marker line.  The index.yaml file is
# automatically uploaded to the admin console when you next deploy
# your application using appcfg.py."""
