Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add schema checking for HyVee #716

Closed
Mr0grog opened this issue Jun 16, 2022 · 0 comments · Fixed by #1495
Closed

Add schema checking for HyVee #716

Mr0grog opened this issue Jun 16, 2022 · 0 comments · Fixed by #1495

Comments

@Mr0grog
Copy link
Collaborator

Mr0grog commented Jun 16, 2022

In #714, I had to make some changes to HyVee and noticed that the data we get from them is no longer quite the same (it was not different enough to be problematic, but there was drift).

We should add schema checking using assertSchema for the data we get from HyVee, just like we added for Rite Aid in #532 and #547:

// API data for each location should look like this. The schema is fairly strict
// since we are pulling on an unversioned API designed for the web UI, and want
// the system to scream at us for any potentially impactful change.
const riteAidLocationSchema = {
type: "object",
properties: {
storeNumber: { type: "integer", minimum: 1 },
brand: { enum: ["RITEAID", "BARTELL", "UNKNOWN", null] },
customDisplayName: { type: "string", nullable: true },
address: { type: "string" },
city: { type: "string" },
state: { type: "string", pattern: "[A-Z]{2}" },
zipcode: { type: "string", pattern: "\\d{1,5}" },
timeZone: {
enum: ["EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", "PDT"],
},
fullZipCode: { type: "string", pattern: "\\d{1,5}-\\d{1,4}" },
fullPhone: { type: "string", nullable: true },
locationDescription: { type: "string" },
storeType: { enum: ["CORE"] },
latitude: { type: "number" },
longitude: { type: "number" },
name: { type: "string" },
milesFromCenter: { type: "number", minimum: 0 },
totalSlotCount: { type: "integer", minimum: 0 },
totalAvailableSlots: { type: "integer", minimum: 0 },
firstAvailableSlot: { type: "string", format: "date", nullable: true },
specialServiceKeys: { type: "array", items: { type: "string" } },
availableSlots: {
type: "array",
items: {
type: "object",
properties: {
date: { type: "string", format: "date" },
available_slots: { type: "integer", minimum: 0 },
slots: {
type: "object",
patternProperties: {
"\\d+": {
type: "array",
items: {
type: "object",
properties: {
appointmentId: { type: "string", pattern: "\\d+" },
apptDateTime: { type: "string" },
},
required: ["appointmentId", "apptDateTime"],
additionalProperties: false,
},
},
},
additionalProperties: false,
},
},
required: ["date", "available_slots", "slots"],
additionalProperties: false,
},
},
},
additionalProperties: false,
};
riteAidLocationSchema.required = Object.keys(riteAidLocationSchema.properties);
function formatLocation(apiData) {
assertSchema(riteAidLocationSchema, apiData);

@Mr0grog Mr0grog assigned Mr0grog and unassigned Mr0grog Jun 16, 2022
@Mr0grog Mr0grog added the P2 label Sep 12, 2022
Mr0grog added a commit that referenced this issue May 16, 2023
Pretty strightforward. Actually kind of glad I added this, since it showed me our tests were running agains stale data with an old, different schema.

Fixes #716.
Mr0grog added a commit that referenced this issue May 16, 2023
Pretty strightforward. Actually kind of glad I added this, since it showed me our tests were running agains stale data with an old, different schema.

Fixes #716.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant