Skip to content

Commit f55b971

Browse files
committed
Better way to add a new field
1 parent 0e55e48 commit f55b971

File tree

9 files changed

+10
-18
lines changed

9 files changed

+10
-18
lines changed

readthedocs/projects/models.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ def get_processed_json(self):
12451245
for fjson_path in fjson_paths:
12461246
file_path = os.path.join(full_json_path, fjson_path)
12471247
if os.path.exists(file_path):
1248-
return process_file(file_path, self.path)
1248+
return process_file(file_path)
12491249
except Exception:
12501250
log.warning(
12511251
'Unhandled exception during search processing file: %s',
@@ -1255,7 +1255,6 @@ def get_processed_json(self):
12551255
'headers': [],
12561256
'content': '',
12571257
'path': file_path,
1258-
'full_path': self.path,
12591258
'title': '',
12601259
'sections': [],
12611260
}

readthedocs/search/documents.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class PageDocument(RTDDocTypeMixin, DocType):
116116
project = fields.KeywordField(attr='project.slug')
117117
version = fields.KeywordField(attr='version.slug')
118118
path = fields.KeywordField(attr='processed_json.path')
119-
full_path = fields.KeywordField(attr='processed_json.full_path')
119+
full_path = fields.KeywordField(attr='path')
120120

121121
# Searchable content
122122
title = fields.TextField(attr='processed_json.title')

readthedocs/search/parse_json.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def generate_sections_from_pyquery(body):
5959
}
6060

6161

62-
def process_file(fjson_filename, filename):
62+
def process_file(fjson_filename):
6363
"""Read the fjson file from disk and parse it into a structured dict."""
6464
try:
6565
with codecs.open(fjson_filename, encoding='utf-8', mode='r') as f:
@@ -76,7 +76,7 @@ def process_file(fjson_filename, filename):
7676
if 'current_page_name' in data:
7777
path = data['current_page_name']
7878
else:
79-
log.info('Unable to index file due to no name %s', filename)
79+
log.info('Unable to index file due to no name %s', fjson_filename)
8080

8181
if data.get('body'):
8282
body = PyQuery(data['body'])
@@ -96,7 +96,6 @@ def process_file(fjson_filename, filename):
9696
'headers': process_headers(data, fjson_filename),
9797
'content': body_content,
9898
'path': path,
99-
'full_path': filename,
10099
'title': title,
101100
'sections': sections,
102101
}

readthedocs/search/tests/data/docs/story.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,5 @@
2727
"title": "Rationale"
2828
}
2929
],
30-
"path": "open-source-philosophy",
31-
"full_path": "open-source-philosophy.html"
30+
"path": "open-source-philosophy"
3231
}

readthedocs/search/tests/data/docs/wiping.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
"title": "Wiping a Build Environment"
1212
}
1313
],
14-
"path": "guides/wipe-environment",
15-
"full_path": "guides/wipe-environment.html"
14+
"path": "guides/wipe-environment"
1615
}

readthedocs/search/tests/data/kuma/docker.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,5 @@
2121
"title": "Docker Images"
2222
}
2323
],
24-
"path": "docker",
25-
"full_path": "docker.html"
24+
"path": "docker"
2625
}

readthedocs/search/tests/data/kuma/documentation.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@
1717
"title": "Generating documentation"
1818
}
1919
],
20-
"path": "documentation",
21-
"full_path": "documentation.html"
20+
"path": "documentation"
2221
}

readthedocs/search/tests/data/pipeline/installation.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,5 @@
2929
"title": "Recommendations"
3030
}
3131
],
32-
"path": "installation",
33-
"full_path": "installation.html"
32+
"path": "installation"
3433
}

readthedocs/search/tests/data/pipeline/signals.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,5 @@
2323
"title": "js_compressed"
2424
}
2525
],
26-
"path": "signals",
27-
"full_path": "signals.html"
26+
"path": "signals"
2827
}

0 commit comments

Comments
 (0)