Skip to content

Commit 361c574

Browse files
Pa04rthnorthdpole
authored andcommitted
Added numericise_ignore in spreadsheet.py file
1 parent 01801df commit 361c574

File tree

4 files changed

+19
-23
lines changed

4 files changed

+19
-23
lines changed

application/database/db.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -679,16 +679,6 @@ def __init__(self) -> None:
679679
self.neo_db = NEO_DB.instance()
680680
self.session = sqla.session
681681

682-
def get_resources(self):
683-
# Query to fetch distinct resource names from the Node table
684-
resources = (
685-
self.session.query(Node.name)
686-
.filter(Node.ntype == cre_defs.Credoctypes.Standard.value)
687-
.distinct()
688-
.all()
689-
)
690-
return [resource[0] for resource in resources]
691-
692682
def with_graph(self) -> "Node_collection":
693683
logger.info("Loading CRE graph in memory, memory-heavy operation!")
694684
self.graph = inmemory_graph.CRE_Graph()

application/tests/spreadsheet_test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,20 @@ def test_prepare_spreadsheet(self) -> None:
107107
result = list(csv.DictReader(out))
108108

109109
self.assertCountEqual(result, expected)
110+
111+
# def get_spreadsheet_url(self) -> str:
112+
# """Helper function to retrieve the spreadsheet URL from an environment variable."""
113+
# return os.environ.get("TEST_SPREADSHEET_URL", "https://docs.google.com/spreadsheets/d/1IgfpPw5TCKSJ4eDlzfI9oNwVOZgtXQvWxSbC7SHE7Zg")
114+
115+
# def test_read_spreadsheet_iso_numbers(self) -> None:
116+
# url = self.get_spreadsheet_url()
117+
# alias = "Test Spreadsheet"
118+
# result = read_spreadsheet(url, alias, validate=False, parse_numbered_only=False)
119+
120+
# # Assuming the spreadsheet has a column "ISO Number" with values "7.10" and "8.20"
121+
# expected = [
122+
# {"ISO Number": "7.10", "Name": "Example 1", "Value": 10},
123+
# {"ISO Number": "8.20", "Name": "Example 2", "Value": 20}
124+
# ]
125+
126+
# self.assertEqual(result["Sheet1"], expected)

application/utils/spreadsheet.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ def read_spreadsheet(
5959
" will be processed by convention)" % wsh.title
6060
)
6161
records = wsh.get_all_records(
62-
wsh.row_values(1)
62+
head=1, numericise_ignore=["ISO Number"] # Added numericise_ignore parameter
6363
) # workaround because of https://github.com/burnash/gspread/issues/1007 # this will break if the column names are in any other line
6464
toyaml = yaml.safe_load(yaml.safe_dump(records))
6565
result[wsh.title] = toyaml
6666
elif not parse_numbered_only:
6767
records = wsh.get_all_records(
68-
wsh.row_values(1)
68+
head=1, numericise_ignore=["ISO Number"] # Added numericise_ignore parameter
6969
) # workaround because of https://github.com/burnash/gspread/issues/1007 # this will break if the column names are in any other line
7070
toyaml = yaml.safe_load(yaml.safe_dump(records))
7171
result[wsh.title] = toyaml
@@ -81,7 +81,6 @@ def read_spreadsheet(
8181

8282
return result
8383

84-
8584
class ExportSheet:
8685
processed_ids = []
8786
body = []

application/web/web_main.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -253,16 +253,6 @@ def find_document_by_tag() -> Any:
253253
abort(404, "Tag does not exist")
254254

255255

256-
# , to ensure that ISO numbers are treated as strings when fetched from the database and returned in API responses ,
257-
@app.route("/api/resources", methods=["GET"])
258-
def get_resources():
259-
database = db.Node_collection()
260-
resources = database.get_resources() # Fetch resources from the database
261-
iso_numbers = ["7.1", "7.10", "8.1", "8.10"]
262-
resources.extend(iso_numbers)
263-
return jsonify(resources)
264-
265-
266256
@app.route("/rest/v1/map_analysis", methods=["GET"])
267257
def map_analysis() -> Any:
268258
standards = request.args.getlist("standard")

0 commit comments

Comments
 (0)