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

WIP 1031: Bulk Data Import Frontend #1104

Draft
wants to merge 22 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 0 additions & 49 deletions .env

This file was deleted.

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ content
.env.local
.env.test.local
*.pem
.vscode/launch.json

.lighthouseci

# IDE
.idea/
.vscode/launch.json
.vscode/settings.json
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"[typescriptreact]": {
"editor.formatOnType": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "standard.vscode-standard"
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"[typescript]": {
"editor.formatOnSave": true,
Expand All @@ -15,5 +15,6 @@
"standard.treatErrorsAsWarnings": true,
"javascript.format.enable": false,
"javascript.format.semicolons": "remove",
"typescript.format.enable": true
"typescript.format.enable": true,
"workbench.colorTheme": "Tomorrow Night Blue"
}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@
"@turf/line-to-polygon": "^6.5.0",
"@udecode/zustood": "^1.1.3",
"@vercel/edge": "^1.1.1",
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1",
"auth0": "^2.42.0",
"awesome-debounce-promise": "^2.1.0",
"aws-sdk": "^2.1265.0",
"axios": "^0.24.0",
"better-ajv-errors": "^1.2.0",
"classnames": "^2.3.1",
"csvtojson": "^2.0.10",
"daisyui": "^3.9.4",
Expand All @@ -43,6 +46,7 @@
"graphql": "^16.2.0",
"i18n-iso-countries": "^7.5.0",
"immer": "^10.0.2",
"json-to-graphql-query": "^2.2.5",
"lexical": "^0.7.5",
"mapbox-gl": "^2.7.0",
"nanoid": "^4.0.0",
Expand Down
72 changes: 72 additions & 0 deletions public/bulk-import/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Introduction
This readme is supplementary information to the bulk import feature of OpenBeta.io (https://openbeta.io/import).

# Data Validation
## Client-Side Schema Validation
All uploaded data is validated against a JSON schema in the user's browser beforehand. The schema represents a simplified version of the actual database schema, specifically tailored to end-users in order to make it comfortable to mass-contribute climbing data to OpenBeta without needing to dive deep into technicalities. (For a full specification of the database, please refer to https://github.com/OpenBeta/openbeta-graphql).

## Server-Side Schema Validation
Each upload is tested against the database as an uncommitted transaction, only if each line has passed the validation against the database the whole file will be written.

# Example Files
This document will refer to the following example files:
* The schema file used for client-side validation: `https://openbeta.io/bulk-import/schema.json` (use the schema locally by adding `"$schema": "schema.json"` to the first line of your JSON file to be uploaded)
* Example files that guide you how to structure your JSON files for mass upload are located at TODO: Link to GitHub dir

# Schema
## General Data Hierarchy
This is how OpenBeta's data is structured. Generally speaking, the database schema distinguishes between `Area`s and `Climb`s:

> - Country (`Area`)
> - Region (`Area`)
> - Sub-Region (`Area`)
> - Sub-Sub-Region (`Area`)
> - Crag 1 (`Area`)
> - Sector 1 (`Area`)
> - Sector 2 (`Area`)
> - Sector N (`Area`)
> - Climb 1 (`Climb`)
> - Climb 2 (`Climb`)
> - Climb N (`Climb`)
> - Pitch 1 (`Climb.Pitch`)
> - Pitch 2 (`Climb.Pitch`)
> - Crag 2 (`Area`)
> - Crag N (`Area`)


## Example
Let's look at the example `add-areas-with-climbs.json` for an illustration:

> - "USA" (Country, Type: `Area`)
> - "Utah" (State, Type: `Area`)
> - "Southeast Utah" (Region, Type: `Area`)
> - "Indian Creek" (Crag, Type: `Area`)
> - "Supercrack Buttress" (Sector, Type: `Area`)
> - "The Key Flake" (Route, Type: `Climb`)
> - "Incredible Hand Crack" (Route, Type: `Climb`)
> - "Pitch 1" (Pitch, Type: `Climb.Pitch`)
> - "Pitch 2" (Pitch, Type: `Climb.Pitch`)

## Using the schema.json


### A note on `Area`s
* An `Area` may be a country, state, region, crag or sector (and may be infinetely nested)
* It is only the leaf area node that determines its type, which is (moslty) automatically determined server-side based on certain criteria:
* an area with *climbs* => a *sector*
* an area with *sectors* => a *crag*
* an area with *only boulder routes* as children => *boulder field*

# How to Update Data
* On the use of `uuid`s for `Area`, `Climb`, or `Climb.Pitch`:
* The schema requires EITHER
*`name` (for areas: `areaName`)
* OR `uuid` (for pitches: `id`)
* omitting a uuid => **creates** new entries
* providing a uuid => **updates** existing entries

* Deleting climbs is not supported (join our Discord for help: https://discord.gg/a6vuuTQxS8)

# Nightly Database Dump
* Find all current database data here: https://github.com/OpenBeta/openbeta-export/tree/production (updated nightly)

Loading