Skip to content

Commit

Permalink
Adding 50 and 100 distances (#386)
Browse files Browse the repository at this point in the history
Conditionally trim them if they don't add new
results, unless was requested via query param
  • Loading branch information
gkovats authored May 3, 2024
1 parent 18b14d6 commit 0dec1c2
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 2 deletions.
2 changes: 1 addition & 1 deletion public/app.js

Large diffs are not rendered by default.

169 changes: 169 additions & 0 deletions public/data/atlanta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
[
{
"id": 65301,
"name": "Early Sunday Morning",
"slug": "early-sunday-morning",
"notes": "Dr. Bob Room",
"updated": "2024-03-08 01:55:57",
"location_id": 65300,
"url": "https://atlantaaa.org/meetings/early-sunday-morning/",
"day": 0,
"time": "09:00",
"end_time": "10:00",
"time_formatted": "9:00 AM",
"edit_url": "https://atlantaaa.org/wp-admin/post.php?post=65301&action=edit",
"types": ["C", "D"],
"author": "smoore",
"location": "H.O.W. Place",
"location_url": "https://atlantaaa.org/locations/h-o-w-place/",
"formatted_address": "5881 Old Bascomb Rd, Acworth, GA 30102, USA",
"approximate": "no",
"latitude": 34.099303300000002536762622185051441192626953125,
"longitude": -84.5794460000000043464751797728240489959716796875,
"region_id": 1927,
"region": "Acworth",
"regions": ["Acworth"],
"group_id": 65299,
"group": "Early Sunday Morning",
"website": "https://howplace.org/",
"attendance_option": "in_person"
},
{
"id": 65347,
"name": "Sunday Serenity and Spirituality",
"slug": "serenity-and-spirituality",
"updated": "2024-03-08 01:46:46",
"location_id": 65300,
"url": "https://atlantaaa.org/meetings/serenity-and-spirituality/",
"day": 0,
"time": "11:00",
"end_time": "12:00",
"time_formatted": "11:00 AM",
"edit_url": "https://atlantaaa.org/wp-admin/post.php?post=65347&action=edit",
"types": ["D", "O"],
"author": "smoore",
"location": "H.O.W. Place",
"location_url": "https://atlantaaa.org/locations/h-o-w-place/",
"formatted_address": "5881 Old Bascomb Rd, Acworth, GA 30102, USA",
"approximate": "no",
"latitude": 34.099303300000002536762622185051441192626953125,
"longitude": -84.5794460000000043464751797728240489959716796875,
"region_id": 1927,
"region": "Acworth",
"regions": ["Acworth"],
"group_id": 65346,
"group": "Serenity and Spirituality",
"website": "https://howplace.org/",
"attendance_option": "in_person"
},
{
"id": 65411,
"name": "Sunday Meeting",
"slug": "sunday-meeting",
"updated": "2024-03-08 03:01:13",
"location_id": 65300,
"url": "https://atlantaaa.org/meetings/sunday-meeting/",
"day": 0,
"time": "16:00",
"end_time": "17:00",
"time_formatted": "4:00 PM",
"edit_url": "https://atlantaaa.org/wp-admin/post.php?post=65411&action=edit",
"types": ["D", "O", "X"],
"author": "smoore",
"location": "H.O.W. Place",
"location_url": "https://atlantaaa.org/locations/h-o-w-place/",
"formatted_address": "5881 Old Bascomb Rd, Acworth, GA 30102, USA",
"approximate": "no",
"latitude": 34.099303300000002536762622185051441192626953125,
"longitude": -84.5794460000000043464751797728240489959716796875,
"region_id": 1927,
"region": "Acworth",
"regions": ["Acworth"],
"website": "https://howplace.org/",
"attendance_option": "in_person"
},
{
"id": 65483,
"name": "Original H.O.W.",
"slug": "original-h-o-w",
"updated": "2014-01-16 08:41:00",
"location_id": 65300,
"url": "https://atlantaaa.org/meetings/original-h-o-w/",
"day": 0,
"time": "19:00",
"end_time": "20:00",
"time_formatted": "7:00 PM",
"edit_url": "https://atlantaaa.org/wp-admin/post.php?post=65483&action=edit",
"types": ["C", "D", "X"],
"author": "smoore",
"location": "H.O.W. Place",
"location_url": "https://atlantaaa.org/locations/h-o-w-place/",
"formatted_address": "5881 Old Bascomb Rd, Acworth, GA 30102, USA",
"approximate": "no",
"latitude": 34.099303300000002536762622185051441192626953125,
"longitude": -84.5794460000000043464751797728240489959716796875,
"region_id": 1927,
"region": "Acworth",
"regions": ["Acworth"],
"group_id": 65482,
"group": "Original H.O.W.",
"website": "https://howplace.org/",
"attendance_option": "in_person"
},
{
"id": 65376,
"name": "Covington",
"slug": "covington-4",
"updated": "2021-08-17 04:21:00",
"location_id": 65375,
"url": "https://atlantaaa.org/meetings/covington-4/",
"day": 0,
"time": "12:00",
"end_time": "13:00",
"time_formatted": "Noon",
"edit_url": "https://atlantaaa.org/wp-admin/post.php?post=65376&action=edit",
"types": ["D", "O"],
"author": "smoore",
"location": "Serenity House - Covington",
"location_url": "https://atlantaaa.org/locations/serenity-house-covington/",
"formatted_address": "10102 Old Atlanta Hwy, Covington, GA 30014, USA",
"approximate": "no",
"latitude": 33.61095060000000245281626121141016483306884765625,
"longitude": -83.8833096999999980880602379329502582550048828125,
"region_id": 1937,
"region": "Covington",
"regions": ["Covington"],
"group_id": 65374,
"group": "Covington",
"last_contact": "2021-08-16",
"attendance_option": "in_person"
},
{
"id": 65494,
"name": "Covington",
"slug": "covington-11",
"updated": "2021-08-17 04:25:00",
"location_id": 65375,
"url": "https://atlantaaa.org/meetings/covington-11/",
"day": 0,
"time": "19:00",
"end_time": "20:00",
"time_formatted": "7:00 PM",
"edit_url": "https://atlantaaa.org/wp-admin/post.php?post=65494&action=edit",
"types": ["D", "O", "X"],
"author": "smoore",
"location": "Serenity House - Covington",
"location_url": "https://atlantaaa.org/locations/serenity-house-covington/",
"formatted_address": "10102 Old Atlanta Hwy, Covington, GA 30014, USA",
"approximate": "no",
"latitude": 33.61095060000000245281626121141016483306884765625,
"longitude": -83.8833096999999980880602379329502582550048828125,
"region_id": 1937,
"region": "Covington",
"regions": ["Covington"],
"group_id": 65374,
"group": "Covington",
"last_contact": "2021-08-16",
"attendance_option": "in_person"
}
]
41 changes: 41 additions & 0 deletions public/tests/atlanta.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="description" content="React JS recovery meeting finder demo" />
<link rel="icon" type="image/png" href="/logo.png" />
<title>Meetings</title>
<style type="text/css">
body {
margin: 0;
}
#tsml-ui {
min-height: 100vh;
min-height: -webkit-fill-available;
}
</style>
</head>
<body>
<div
id="tsml-ui"
data-src="/data/atlanta.json"
data-mapbox="pk.eyJ1IjoiYWFzZi1tcGFsIiwiYSI6ImNqaHl6NHY0NzByemszcHBkcHpib296OHkifQ.F7GfpF1jRosyQ0PGNUfDkA"
data-timezone="America/New_York"
></div>
<script>
var tsml_react_config = {
'timezone': 'America/New_York',
'flags': ['M', 'W', 'X', 'TC'],
'strings': {
'en': { 'types': { 'X': 'Wheelchair', 'TC': 'Temp Closed' } },
},
'feedback_url': 'https://atlantaaa.org/',
};
</script>
<script src="/app.js" async></script>
</body>
</html>
12 changes: 12 additions & 0 deletions src/helpers/calculate-distances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ export function calculateDistances({
});
});

//remove redundant distances at 50 and higher distances, unless requested via query param
let slugMax = 0;
let queryDistance = Array.isArray(state.input?.distance) ? state.input.distance[0] : 0;
Object.entries(distances).forEach(([val, distance]) => {
if (50 <= parseInt(val) && val !== queryDistance) {
if (slugMax >= distance.slugs.length) {
delete distances[val];
}
}
slugMax = Math.max(slugMax, distance.slugs.length);
})

//flatten index and set capability
const distanceIndex = flattenAndSortIndexes(
// @ts-expect-error TODO
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const defaults: TSMLReactConfig = {
view: 'table',
weekday: [],
},
distance_options: [1, 2, 5, 10, 15, 25],
distance_options: [1, 2, 5, 10, 15, 25, 50, 100],
distance_unit: 'mi', //mi or km
duration: 60,
feedback_emails: [], //email addresses for update meeting info button
Expand Down

0 comments on commit 0dec1c2

Please sign in to comment.