4 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 - able to easily modify search + results template
- mapping out where everything is - mapping out where everything is
## Round 2 ## Round 2 (done)
improvements: improvements:
- storing comments and issues as separate objects? - 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, - if so, how do we pass off a search result to a template conditionally,
such that we can save some space (jinja question) 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: fix stuff that isn't mine:
- improve the readme - improve the readme
- fix the config.py config file options - fix the config.py config file options
@@ -28,3 +24,8 @@ config:
- enable user to specify list of organizations+repos - enable user to specify list of organizations+repos
- not just one org/list of 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': if fields == 'None':
fields = None fields = None
directories = []
search = Search(app.config["INDEX_DIR"]) search = Search(app.config["INDEX_DIR"])
if not query: if not query:
parsed_query = "" parsed_query = ""
result = [] result = []
directories=get_directories()
else: else:
parsed_query, result = search.search(query.split(), fields=[fields]) parsed_query, result = search.search(query.split(), fields=[fields])
@@ -76,7 +74,7 @@ def search():
total = search.get_document_total_count() 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') @app.route('/open')
def open_file(): def open_file():
@@ -96,7 +94,6 @@ def update_index():
else: else:
UpdateIndexTask() UpdateIndexTask()
flash("Updating index, check console output") flash("Updating index, check console output")
store_directories()
return render_template("search.html", query="", fields="", last_searches=get_last_searches()) return render_template("search.html", query="", fields="", last_searches=get_last_searches())
@@ -109,18 +106,7 @@ def get_last_searches():
return contents 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): def store_search(query, fields):
'''remove for issues'''
if os.path.exists(last_searches_file): if os.path.exists(last_searches_file):
with codecs.open(last_searches_file, 'r', encoding='utf-8') as f: with codecs.open(last_searches_file, 'r', encoding='utf-8') as f:
contents = f.readlines() contents = f.readlines()
@@ -134,17 +120,6 @@ def store_search(query, fields):
with codecs.open(last_searches_file, 'w', encoding='utf-8') as f: with codecs.open(last_searches_file, 'w', encoding='utf-8') as f:
f.writelines(contents[:30]) 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__': if __name__ == '__main__':
app.run() app.run()

View File

@@ -17,6 +17,16 @@ from whoosh.analysis import StemmingAnalyzer
""" """
issues-search.py Flow: 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: program will:
- create a Search object - create a Search object
- call add_all_issues - call add_all_issues
@@ -172,6 +182,7 @@ class Search:
return count return count
'''
def add_all_issues(self, gh_access_token, list_of_repos, which_org, config, create_new_index=False): 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. Add all issues in a given github repo to the search index.
@@ -218,6 +229,8 @@ class Search:
writer.commit() writer.commit()
print("Done, added %d documents to the index" % c) 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): def update_index_incremental(self, gh_access_token, list_of_repos, which_org, config, create_new_index=False):