Skip to content
Merged
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
9 changes: 9 additions & 0 deletions examples/orcid-works/filter.jq
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# a) 0th: edit title & backdate last-modified-date (→ to be updated)
(.records[0].title.title.value) |= "Title to be updated"
| (.records[0]."last-modified-date".value) -= 86400000
# b) 1st) duplicate and change title & put-code (→ to be deleted)
| .records += [.records[1]]
| (.records[1]."put-code") |= 999999
| (.records[1].title.title.value) |= "Title to be deleted"
# c) 2nd: remove (→ to be added)
| del(.records[2])
24 changes: 24 additions & 0 deletions examples/orcid-works/test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env pwsh

# 0) set your ORCID ID or sample ID
$ORCID_ID = "0000-0002-1825-0097"

# 1) initial fetch
cargo run -p orcid-works-cli -- -i "$ORCID_ID" -o output.json

# 2) mangle the JSON (requires at least 3 records)
jq -f filter.jq output.json > output-modified.json
Copy-Item output-modified.json -Destination output-modified-1.json
Copy-Item output-modified.json -Destination output-modified-2.json

# 3) refetch (diff-aware)
cargo run -p orcid-works-cli -- -i "$ORCID_ID" -o output-modified-1.json
# => only missing/changed records are fetched

# 3') force-fetch (bypass diff)
cargo run -p orcid-works-cli -- -i "$ORCID_ID" -o output-modified-2.json --force-fetch
# => all records are fetched

# 4) compare results (expected: identical)
Compare-Object output.json output-modified-1.json
Compare-Object output.json output-modified-2.json
24 changes: 24 additions & 0 deletions examples/orcid-works/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

# 0) set your ORCID ID or sample ID
ORCID_ID="0000-0002-1825-0097"

# 1) initial fetch
cargo run -p orcid-works-cli -- -i "$ORCID_ID" -o output.json

# 2) mangle the JSON (requires at least 3 records)
jq -f filter.jq output.json > output-modified.json
cp output-modified.json output-modified-1.json
cp output-modified.json output-modified-2.json

# 3) refetch (diff-aware)
cargo run -p orcid-works-cli -- -i "$ORCID_ID" -o output-modified-1.json
# => only missing/changed records are fetched

# 3') force-fetch (bypass diff)
cargo run -p orcid-works-cli -- -i "$ORCID_ID" -o output-modified-2.json --force-fetch
# => all records are fetched

# 4) compare results (expected: identical)
diff -q output.json output-modified-1.json
diff -q output.json output-modified-2.json
Loading