3 Commits

3 changed files with 20 additions and 31 deletions

11
Todo.md
View File

@@ -7,7 +7,7 @@ recap of round 1:
- able to easily modify search + results template
- mapping out where everything is
## Round 2
## Round 2 (done)
improvements:
- storing comments and issues as separate objects?
@@ -16,10 +16,6 @@ improvements:
- if so, how do we pass off a search result to a template conditionally,
such that we can save some space (jinja question)
organization:
- mapping out how to change the schema... now, how do we streamline it?
- how to organize files
fix stuff that isn't mine:
- improve the readme
- fix the config.py config file options
@@ -28,3 +24,8 @@ config:
- enable user to specify list of organizations+repos
- not just one org/list of repos
## Round 3
organization:
- mapping out how to change the schema... now, how do we streamline it?
- how to organize files

View File

@@ -63,12 +63,10 @@ def search():
if fields == 'None':
fields = None
directories = []
search = Search(app.config["INDEX_DIR"])
if not query:
parsed_query = ""
result = []
directories=get_directories()
else:
parsed_query, result = search.search(query.split(), fields=[fields])
@@ -76,7 +74,7 @@ def search():
total = search.get_document_total_count()
return render_template('search.html', entries=result, query=query, parsed_query=parsed_query, fields=fields, last_searches=get_last_searches(), directories=directories, total=total)
return render_template('search.html', entries=result, query=query, parsed_query=parsed_query, fields=fields, last_searches=get_last_searches(), total=total)
@app.route('/open')
def open_file():
@@ -96,7 +94,6 @@ def update_index():
else:
UpdateIndexTask()
flash("Updating index, check console output")
store_directories()
return render_template("search.html", query="", fields="", last_searches=get_last_searches())
@@ -109,18 +106,7 @@ def get_last_searches():
return contents
def get_directories():
'''remove for issues'''
if os.path.exists(directories_file):
with codecs.open(directories_file, 'r', encoding='utf-8') as f:
directories = f.readlines()
f.close()
else:
directories = []
return directories
def store_search(query, fields):
'''remove for issues'''
if os.path.exists(last_searches_file):
with codecs.open(last_searches_file, 'r', encoding='utf-8') as f:
contents = f.readlines()
@@ -134,17 +120,6 @@ def store_search(query, fields):
with codecs.open(last_searches_file, 'w', encoding='utf-8') as f:
f.writelines(contents[:30])
def store_directories():
'''remove for issues'''
directories = []
for root, dirnames, files in os.walk(app.config["MARKDOWN_FILES_DIR"]):
if dirnames:
for d in dirnames:
if os.path.isdir(os.path.join(root, d)):
directories.append("%s\n" % d.lower())
directories = sorted(set(directories))
with codecs.open(app.config["INDEX_DIR"] + "/directories.txt", 'w', encoding='utf-8') as f:
f.writelines(directories)
if __name__ == '__main__':
app.run()

View File

@@ -17,6 +17,16 @@ from whoosh.analysis import StemmingAnalyzer
"""
issues-search.py Flow:
very high level description:
- zeroth step: create a search index
- first step: load a search index
- second step: call the search() method
- third step: update the search index
program will:
- create a Search object
- call add_all_issues
@@ -172,6 +182,7 @@ class Search:
return count
'''
def add_all_issues(self, gh_access_token, list_of_repos, which_org, config, create_new_index=False):
"""
Add all issues in a given github repo to the search index.
@@ -218,6 +229,8 @@ class Search:
writer.commit()
print("Done, added %d documents to the index" % c)
'''
def update_index_incremental(self, gh_access_token, list_of_repos, which_org, config, create_new_index=False):