You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
6.7 KiB
6.7 KiB
<html>
<head>
</head>
</html>
In [138]:
import json
# from json import JSONEncoder
import os
import pprint
from gql import Client, gql
from gql.transport.requests import RequestsHTTPTransport
cwd = os.getcwd()
print(cwd)
/home/jovyan
In [139]:
with open("scrubbed_records.json") as f:
scrubbed_records = json.load(f)
# with open("keys.json") as key1:
# keys = json.load(key1);
# print(scrubbed_records[0])
# d8 = keys | scrubbed_records
# print(d8)
# merged = {key: value for (key, value) in (keys.items() + scrubbed_records.items())}
# jsonString_merged =
In [ ]:
In [140]:
# print(jsonString_merged)
In [ ]:
sample_transport = RequestsHTTPTransport(
url="http://directus:8055/graphql",
use_json=True,
headers={
"Content-type": "application/json",
"Authorization": "os.env(directus_token)",
},
verify=True,
retries=3,
)
client = Client(
transport=sample_transport,
fetch_schema_from_transport=True,
)
job_posts = gql(
"""
mutation{
update_job_posts_item(id: ______, data: ______){
id
status
sort
date_created
date_updated
json_object
}
}
"""
)
y = json.dumps(scrubbed_records)
for x in y:
# ef = x.loads()
# print(x)
# id = x["article_attributes_data-listing-version-key"]
# pairs = y.items()
pprint.pprint(x)
# print(y)
# id = y["article_attributes_data-listing-version-key"]
# print(id)
# data = y[scrubbed_record]
# print(scrubbed_record)
# Mutation ($data: JSON!) {
# update_job_blocks_item(
# id: "ziprecruiter"
# data: {
# title: $title
# }
# )
# }
# title = 'article_attributes_data-posted-on'
# "article_attributes_data-posted-on": "Capital One",
# "article_attributes_data-listing-version-key": "DwJbw6IxmCHCl9sUWenVkQ.--M7HviTGj7",
# "article_attributes_data-job-id": "tmp_dc_capitalone_tier2_perengo_cpc9e35f5e59e35f5e5-lzqj0cb",
# "article_attributes_data-location": "Royse City, TX",
# "article_attributes_data-lat": 32.9751205444,
# "article_attributes_data-lng": -96.3324813843,
# print(title)
# params = { "title": article_attributes_data-posted-on }
# result = client.execute(mutate, variable_values=params)
In [136]:
import pprint
# print(result)
# query = gql('''
# query {
# json_server_by_id(id: "ziprecruiter") {
# data
# }
# }
# ''')
# mutate = gql(
# """
# mutation ($data: JSON!) {
# update_json_server_item(
# id: "ziprecruiter"
# data: {
# data: $data
# }
# ) {
# data
# }
# }
# """
# )
# add = gql(
# """
# mutation ($create_test_data: [create_test_input!]) {
# create_test_items( data: $create_test_data ) {
# id
# json_object
# }
# }
# """
# )
# init = gql(
# """
# mutation ($collection: String!, $data: !) {
# create_fields_item(collection: "job_posts", data: { field: "title", type: "string" ) {
# collection
# field
# }
# }
# """
# )
# test3 = { "field": "title", type: "string", "meta": { "icon": "title" }, "schema": { "default_value": "null" } }
# params = {"collection": "job_posts", "data": test3}
# result = client.execute(init, variable_values=params)
# # print(result)
In [ ]:
In [ ]: