Skip to content

Commit 73a8006

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 8ef1708 + 51a1398 commit 73a8006

File tree

8 files changed

+242
-138
lines changed

8 files changed

+242
-138
lines changed

.github/workflows/hfUpdate.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Update Huggingface Dataset
22

33
on:
44
schedule: # once daily at 3:05 pm PST (23:05 UTC)
5-
- cron: '5 23 * * *'
5+
- cron: "5 23 * * *"
66

77
jobs:
88
run:
@@ -11,20 +11,20 @@ jobs:
1111
run:
1212
working-directory: scripts/
1313
steps:
14-
- name: Checkout code
15-
uses: actions/checkout@v2
14+
- name: Checkout code
15+
uses: actions/checkout@v2
1616

17-
- name: Set up Python environment
18-
uses: actions/setup-python@v2
19-
with:
20-
python-version: '3.11.x'
17+
- name: Set up Python environment
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: "3.11.x"
2121

22-
- name: Install dependencies
23-
run: pip install -r requirements.txt
22+
- name: Install dependencies
23+
run: pip install -r requirements.txt
2424

25-
- name: Setup environment
26-
run: |
27-
echo "HUGGINGFACE_LOGIN_TOKEN=${{ secrets.HUGGINGFACE_LOGIN_TOKEN }}" > .env
28-
29-
- name: Run script
30-
run: python updateHfDataset.py
25+
- name: Setup environment
26+
run: |
27+
echo "HUGGINGFACE_LOGIN_TOKEN=${{ secrets.HUGGINGFACE_LOGIN_TOKEN }}" > .env
28+
echo "VITE_ENV=${{ secrets.VITE_ENV }}" >> .env
29+
- name: Run script
30+
run: python updateHfDataset.py
File renamed without changes.

package-lock.json

Lines changed: 162 additions & 118 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@
6666
"redux-logger": "^3.0.6",
6767
"redux-saga": "^1.2.3",
6868
"regenerator-runtime": "^0.14.0",
69-
"web-worker": "^1.2.0"
69+
"web-worker": "^1.2.0",
70+
"yup": "^1.6.1"
7071
},
7172
"devDependencies": {
7273
"@testing-library/react": "^12.1.5",

scripts/updateHfDataset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
load_dotenv()
99

1010
# set environment as 'dev' or 'prod'
11-
ENV = os.getenv('VITE_ENV').upper()
11+
ENV = os.getenv('VITE_ENV')
1212

1313
if ENV == 'DEV':
1414
HF_USERNAME = '311-Data-Dev'
@@ -101,4 +101,4 @@ def main():
101101
cleanUp()
102102

103103

104-
main()
104+
main()

settings/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const settings = {
22
map: {
33
debounce: {
4-
duration: 1500, // milliseconds
4+
duration: 100, // milliseconds
55
options: {
66
leading: true, // calls function immediately when invoked (React-friendly)
77
trailing: false, // calls function after last input event fired (Not React-friendly)

utils/DataService.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import DataFrame from 'dataframe-js';
2+
import { object, string, number, date, array } from 'yup';
23

34
const dataResources = {
45
2019: 'pvft-t768',
@@ -12,6 +13,64 @@ export function getDataResources() {
1213
return dataResources;
1314
}
1415

16+
const serviceRequestSchema = object({
17+
actiontaken: string(),
18+
address: string().min(3).max(100).nullable(),
19+
addressverified: string(),
20+
anonymous: string(),
21+
apc: string(),
22+
approximateaddress: string(),
23+
assignto: string(),
24+
cd: string().nullable(),
25+
cdmember: string(),
26+
closeddate: date(),
27+
createdbyuserorganization: string(),
28+
createddate: date(),
29+
direction: string().nullable(),
30+
housenumber: string(),
31+
latitude: number().nullable(),
32+
location: object({
33+
type: string().matches(/Point/),
34+
coordinates: array().of(number()).length(2)
35+
}),
36+
longitude: number().nullable(),
37+
mobileos: string().nullable(),
38+
nc: string(),
39+
ncname: string(),
40+
owner: string(),
41+
policeprecinct: string(),
42+
requestsource: string(),
43+
requesttype: string(),
44+
servicedate: date(),
45+
srnumber: string().length(12),
46+
status: string(),
47+
streetname: string().max(32).nullable(),
48+
suffix: string(),
49+
tbmcolumn: string().length(1),
50+
tbmpage: number().integer().max(999).nullable(),
51+
tbmrow: string().nullable(),
52+
updateddate: date(),
53+
zipcode: string().nullable(),
54+
})
55+
56+
const srArraySchema = array().of(
57+
serviceRequestSchema
58+
)
59+
60+
export async function getServiceRequests() {
61+
try {
62+
// Get 2024 SR data through Socrata API
63+
const response = await fetch("https://data.lacity.org/resource/b7dx-7gc3.json");
64+
const unvalidatedSrs = await response.json();
65+
console.log(unvalidatedSrs);
66+
const validatedSrs = await srArraySchema.validate(unvalidatedSrs);
67+
console.log(validatedSrs);
68+
return validatedSrs;
69+
} catch (error) {
70+
console.error('Error fetching service requests:', error);
71+
}
72+
}
73+
1574
export function getColorMap(discrete) {
1675
if (discrete) {
1776
return [

utils/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,4 @@ export function shuffle(array) {
181181
.map(a => ({ sort: Math.random(), value: a }))
182182
.sort((a, b) => a.sort - b.sort)
183183
.map(a => a.value);
184-
}
184+
}

0 commit comments

Comments
 (0)