Skip to content

Commit

Permalink
Merge pull request #17 from mlibrary/alma-analyticx-api-fix
Browse files Browse the repository at this point in the history
Alma Analytics column heading fix
  • Loading branch information
niquerio authored Dec 5, 2022
2 parents d33bb73 + 831c352 commit 3901f97
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
3 changes: 0 additions & 3 deletions .env-dev-values
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
MARIADB_ROOT_PASSWORD=pass
CIRCULATION_HISTORY_DATABASE_PASSWORD=circulation_history_db_password
DATABASE_HOST=database
CIRC_REPORT_PATH=/circ/report/path
PATRON_REPORT_PATH=/patron/report/path
ALMA_API_HOST=http://falma:4567
RAILS_LOG_TO_STDOUT=1
PROMETHEUS_JOB_NAME=checkout_history
PROMETHEUS_PUSH_GATEWAY=http://pushgateway:9091
3 changes: 3 additions & 0 deletions .env-example
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
ALMA_API_HOST=http://falma:4567
ALMA_API_KEY='YOUR_ALMA_API_KEY'
PUSHMON_URL='http://pushmonurl'
SLACK_URL='http://slackurl'
CIRC_REPORT_PATH=/circ/report/path
PATRON_REPORT_PATH=/patron/report/path
4 changes: 2 additions & 2 deletions lib/tasks/alma_circ_history.rake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace :alma_circ_history do
end
summary[:active_loans] = response.parsed_response.count
response.parsed_response.each do |row|
u = User.find_or_create_by_uniqname(row["Primary Identifier"])
u = User.find_or_create_by_uniqname(row["User Primary Identifier"])
unless u.retain_history
Rails.logger.warn("item_loan '#{row["Item Loan Id"]}' not saved: patron opt out")
next
Expand Down Expand Up @@ -61,7 +61,7 @@ namespace :alma_circ_history do
Rails.logger.error("Alma Report Failed to Load")
next
end
non_expired_users = response.parsed_response.map { |row| row["Primary Identifier"].downcase }
non_expired_users = response.parsed_response.map { |row| row["User Primary Identifier"].downcase }
User.all.each do |user|
uniqname = user.uniqname
if non_expired_users.include?(uniqname)
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/circ_history.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"anies":["<?xml version=\"1.0\" encoding=\"UTF-16\"?><QueryResult>\n <ResumptionToken>FD4848E50CF7B9412AB9E2F57A859EB09FEF805ED57583267C3BEEF999C91E6F4FA240F17C1BABA1CDF00DBC12E0C97F163D8CC5881FFC5A208117904853089A</ResumptionToken>\n <IsFinished>true</IsFinished>\n <ResultXml>\n <rowset>\n <xsd:schema targetNamespace=\"urn:schemas-microsoft-com:xml-analysis:rowset\" xmlns:saw-sql=\"urn:saw-sql\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n <xsd:complexType name=\"Row\">\n <xsd:sequence>\n <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"Column0\" saw-sql:aggregationRule=\"none\" saw-sql:aggregationType=\"nonAgg\" saw-sql:columnHeading=\"0\" saw-sql:displayFormula=\"0\" saw-sql:length=\"4\" saw-sql:precision=\"12\" saw-sql:scale=\"0\" saw-sql:tableHeading=\"\" saw-sql:type=\"integer\" type=\"xsd:int\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"Column1\" saw-sql:aggregationRule=\"none\" saw-sql:aggregationType=\"nonAgg\" saw-sql:columnHeading=\"Author\" saw-sql:displayFormula=\"&quot;Bibliographic Details&quot;.&quot;Author&quot;\" saw-sql:length=\"255\" saw-sql:precision=\"255\" saw-sql:scale=\"0\" saw-sql:tableHeading=\"Bibliographic Details\" saw-sql:type=\"varchar\" type=\"xsd:string\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"Column2\" saw-sql:aggregationRule=\"none\" saw-sql:aggregationType=\"nonAgg\" saw-sql:columnHeading=\"MMS Id\" saw-sql:displayFormula=\"&quot;Bibliographic Details&quot;.&quot;MMS Id&quot;\" saw-sql:length=\"255\" saw-sql:precision=\"255\" saw-sql:scale=\"0\" saw-sql:tableHeading=\"Bibliographic Details\" saw-sql:type=\"varchar\" type=\"xsd:string\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"Column3\" saw-sql:aggregationRule=\"none\" saw-sql:aggregationType=\"nonAgg\" saw-sql:columnHeading=\"Title\" saw-sql:displayFormula=\"&quot;Bibliographic Details&quot;.&quot;Title&quot;\" saw-sql:length=\"4000\" saw-sql:precision=\"4000\" saw-sql:scale=\"0\" saw-sql:tableHeading=\"Bibliographic Details\" saw-sql:type=\"varchar\" type=\"xsd:string\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"Column4\" saw-sql:aggregationRule=\"none\" saw-sql:aggregationType=\"nonAgg\" saw-sql:columnHeading=\"Primary Identifier\" saw-sql:displayFormula=\"&quot;Borrower Details&quot;.&quot;Primary Identifier&quot;\" saw-sql:length=\"255\" saw-sql:precision=\"255\" saw-sql:scale=\"0\" saw-sql:tableHeading=\"Borrower Details\" saw-sql:type=\"varchar\" type=\"xsd:string\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"Column5\" saw-sql:aggregationRule=\"none\" saw-sql:aggregationType=\"nonAgg\" saw-sql:columnHeading=\"Loan Date\" saw-sql:displayFormula=\"&quot;Loan Date&quot;.&quot;Loan Date&quot;\" saw-sql:length=\"6\" saw-sql:precision=\"0\" saw-sql:scale=\"0\" saw-sql:tableHeading=\"Loan Date\" saw-sql:type=\"date\" type=\"xsd:date\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"Column6\" saw-sql:aggregationRule=\"none\" saw-sql:aggregationType=\"nonAgg\" saw-sql:columnHeading=\"Item Loan Id\" saw-sql:displayFormula=\"&quot;Loan Details&quot;.&quot;Item Loan Id&quot;\" saw-sql:length=\"50\" saw-sql:precision=\"50\" saw-sql:scale=\"0\" saw-sql:tableHeading=\"Loan Details\" saw-sql:type=\"varchar\" type=\"xsd:string\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"Column7\" saw-sql:aggregationRule=\"none\" saw-sql:aggregationType=\"nonAgg\" saw-sql:columnHeading=\"Return Date\" saw-sql:displayFormula=\"&quot;Return Date&quot;.&quot;Return Date&quot;\" saw-sql:length=\"6\" saw-sql:precision=\"0\" saw-sql:scale=\"0\" saw-sql:tableHeading=\"Return Date\" saw-sql:type=\"date\" type=\"xsd:date\"/>\n </xsd:sequence>\n </xsd:complexType>\n </xsd:schema>\n <Row>\n <Column0>0</Column0>\n <Column1>Coates, Ta-Nehisi, author.</Column1>\n <Column2>990137640110206381</Column2>\n <Column3>Between the world and me /</Column3>\n <Column4>emcard</Column4>\n <Column5>2020-01-07</Column5>\n <Column6>3159980960006381</Column6>\n <Column7>2021-01-14</Column7>\n </Row>\n <Row>\n <Column0>0</Column0>\n <Column1>Caldwell, John, 1938-</Column1>\n <Column2>990004538640206381</Column2>\n <Column3>Editing early music /</Column3>\n <Column4>AJONES</Column4>\n <Column5>2021-02-08</Column5>\n <Column6>8797507940006381</Column6>\n <Column7>2021-02-08</Column7>\n </Row>\n </rowset>\n </ResultXml>\n</QueryResult>"]}
{"anies":["<?xml version=\"1.0\" encoding=\"UTF-16\"?><QueryResult>\n <ResumptionToken>FD4848E50CF7B9412AB9E2F57A859EB09FEF805ED57583267C3BEEF999C91E6F4FA240F17C1BABA1CDF00DBC12E0C97F163D8CC5881FFC5A208117904853089A</ResumptionToken>\n <IsFinished>true</IsFinished>\n <ResultXml>\n <rowset>\n <xsd:schema targetNamespace=\"urn:schemas-microsoft-com:xml-analysis:rowset\" xmlns:saw-sql=\"urn:saw-sql\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n <xsd:complexType name=\"Row\">\n <xsd:sequence>\n <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"Column0\" saw-sql:aggregationRule=\"none\" saw-sql:aggregationType=\"nonAgg\" saw-sql:columnHeading=\"0\" saw-sql:displayFormula=\"0\" saw-sql:length=\"4\" saw-sql:precision=\"12\" saw-sql:scale=\"0\" saw-sql:tableHeading=\"\" saw-sql:type=\"integer\" type=\"xsd:int\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"Column1\" saw-sql:aggregationRule=\"none\" saw-sql:aggregationType=\"nonAgg\" saw-sql:columnHeading=\"Author\" saw-sql:displayFormula=\"&quot;Bibliographic Details&quot;.&quot;Author&quot;\" saw-sql:length=\"255\" saw-sql:precision=\"255\" saw-sql:scale=\"0\" saw-sql:tableHeading=\"Bibliographic Details\" saw-sql:type=\"varchar\" type=\"xsd:string\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"Column2\" saw-sql:aggregationRule=\"none\" saw-sql:aggregationType=\"nonAgg\" saw-sql:columnHeading=\"MMS Id\" saw-sql:displayFormula=\"&quot;Bibliographic Details&quot;.&quot;MMS Id&quot;\" saw-sql:length=\"255\" saw-sql:precision=\"255\" saw-sql:scale=\"0\" saw-sql:tableHeading=\"Bibliographic Details\" saw-sql:type=\"varchar\" type=\"xsd:string\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"Column3\" saw-sql:aggregationRule=\"none\" saw-sql:aggregationType=\"nonAgg\" saw-sql:columnHeading=\"Title\" saw-sql:displayFormula=\"&quot;Bibliographic Details&quot;.&quot;Title&quot;\" saw-sql:length=\"4000\" saw-sql:precision=\"4000\" saw-sql:scale=\"0\" saw-sql:tableHeading=\"Bibliographic Details\" saw-sql:type=\"varchar\" type=\"xsd:string\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"Column4\" saw-sql:aggregationRule=\"none\" saw-sql:aggregationType=\"nonAgg\" saw-sql:columnHeading=\"User Primary Identifier\" saw-sql:displayFormula=\"&quot;Borrower Details&quot;.&quot;User Primary Identifier&quot;\" saw-sql:length=\"255\" saw-sql:precision=\"255\" saw-sql:scale=\"0\" saw-sql:tableHeading=\"Borrower Details\" saw-sql:type=\"varchar\" type=\"xsd:string\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"Column5\" saw-sql:aggregationRule=\"none\" saw-sql:aggregationType=\"nonAgg\" saw-sql:columnHeading=\"Loan Date\" saw-sql:displayFormula=\"&quot;Loan Date&quot;.&quot;Loan Date&quot;\" saw-sql:length=\"6\" saw-sql:precision=\"0\" saw-sql:scale=\"0\" saw-sql:tableHeading=\"Loan Date\" saw-sql:type=\"date\" type=\"xsd:date\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"Column6\" saw-sql:aggregationRule=\"none\" saw-sql:aggregationType=\"nonAgg\" saw-sql:columnHeading=\"Item Loan Id\" saw-sql:displayFormula=\"&quot;Loan Details&quot;.&quot;Item Loan Id&quot;\" saw-sql:length=\"50\" saw-sql:precision=\"50\" saw-sql:scale=\"0\" saw-sql:tableHeading=\"Loan Details\" saw-sql:type=\"varchar\" type=\"xsd:string\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"Column7\" saw-sql:aggregationRule=\"none\" saw-sql:aggregationType=\"nonAgg\" saw-sql:columnHeading=\"Return Date\" saw-sql:displayFormula=\"&quot;Return Date&quot;.&quot;Return Date&quot;\" saw-sql:length=\"6\" saw-sql:precision=\"0\" saw-sql:scale=\"0\" saw-sql:tableHeading=\"Return Date\" saw-sql:type=\"date\" type=\"xsd:date\"/>\n </xsd:sequence>\n </xsd:complexType>\n </xsd:schema>\n <Row>\n <Column0>0</Column0>\n <Column1>Coates, Ta-Nehisi, author.</Column1>\n <Column2>990137640110206381</Column2>\n <Column3>Between the world and me /</Column3>\n <Column4>emcard</Column4>\n <Column5>2020-01-07</Column5>\n <Column6>3159980960006381</Column6>\n <Column7>2021-01-14</Column7>\n </Row>\n <Row>\n <Column0>0</Column0>\n <Column1>Caldwell, John, 1938-</Column1>\n <Column2>990004538640206381</Column2>\n <Column3>Editing early music /</Column3>\n <Column4>AJONES</Column4>\n <Column5>2021-02-08</Column5>\n <Column6>8797507940006381</Column6>\n <Column7>2021-02-08</Column7>\n </Row>\n </rowset>\n </ResultXml>\n</QueryResult>"]}
2 changes: 1 addition & 1 deletion spec/fixtures/non_expired_patrons.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"anies": [
"<?xml version=\"1.0\" encoding=\"UTF-16\"?><QueryResult>\n <ResumptionToken>632072B515A662E97A07B57A103819787323F10807293E3E9AA67B5020CEB2B3F644B6DAEB725A3B7D0BEE901AF85610163D8CC5881FFC5A208117904853089A</ResumptionToken>\n <IsFinished>true</IsFinished>\n <ResultXml>\n <rowset>\n <xsd:schema targetNamespace=\"urn:schemas-microsoft-com:xml-analysis:rowset\" xmlns:saw-sql=\"urn:saw-sql\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n <xsd:complexType name=\"Row\">\n <xsd:sequence>\n <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"Column0\" saw-sql:aggregationRule=\"none\" saw-sql:aggregationType=\"nonAgg\" saw-sql:columnHeading=\"0\" saw-sql:displayFormula=\"0\" saw-sql:length=\"4\" saw-sql:precision=\"12\" saw-sql:scale=\"0\" saw-sql:tableHeading=\"\" saw-sql:type=\"integer\" type=\"xsd:int\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"Column1\" saw-sql:aggregationRule=\"none\" saw-sql:aggregationType=\"nonAgg\" saw-sql:columnHeading=\"Primary Identifier\" saw-sql:displayFormula=\"&quot;User Details&quot;.&quot;Primary Identifier&quot;\" saw-sql:length=\"255\" saw-sql:precision=\"255\" saw-sql:scale=\"0\" saw-sql:tableHeading=\"User Details\" saw-sql:type=\"varchar\" type=\"xsd:string\"/>\n </xsd:sequence>\n </xsd:complexType>\n </xsd:schema>\n <Row>\n <Column0>0</Column0>\n <Column1>EMCARD</Column1>\n </Row>\n </rowset>\n </ResultXml>\n</QueryResult>"
"<?xml version=\"1.0\" encoding=\"UTF-16\"?><QueryResult>\n <ResumptionToken>632072B515A662E97A07B57A103819787323F10807293E3E9AA67B5020CEB2B3F644B6DAEB725A3B7D0BEE901AF85610163D8CC5881FFC5A208117904853089A</ResumptionToken>\n <IsFinished>true</IsFinished>\n <ResultXml>\n <rowset>\n <xsd:schema targetNamespace=\"urn:schemas-microsoft-com:xml-analysis:rowset\" xmlns:saw-sql=\"urn:saw-sql\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n <xsd:complexType name=\"Row\">\n <xsd:sequence>\n <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"Column0\" saw-sql:aggregationRule=\"none\" saw-sql:aggregationType=\"nonAgg\" saw-sql:columnHeading=\"0\" saw-sql:displayFormula=\"0\" saw-sql:length=\"4\" saw-sql:precision=\"12\" saw-sql:scale=\"0\" saw-sql:tableHeading=\"\" saw-sql:type=\"integer\" type=\"xsd:int\"/>\n <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"Column1\" saw-sql:aggregationRule=\"none\" saw-sql:aggregationType=\"nonAgg\" saw-sql:columnHeading=\"User Primary Identifier\" saw-sql:displayFormula=\"&quot;User Details&quot;.&quot;User Primary Identifier&quot;\" saw-sql:length=\"255\" saw-sql:precision=\"255\" saw-sql:scale=\"0\" saw-sql:tableHeading=\"User Details\" saw-sql:type=\"varchar\" type=\"xsd:string\"/>\n </xsd:sequence>\n </xsd:complexType>\n </xsd:schema>\n <Row>\n <Column0>0</Column0>\n <Column1>EMCARD</Column1>\n </Row>\n </rowset>\n </ResultXml>\n</QueryResult>"
]
}

0 comments on commit 3901f97

Please sign in to comment.