.tangled/images/apiWalk.jpg
.tangled/images/apiWalk.jpg
This is a binary file and will not be displayed.
+1
-1
src/App.svelte
+1
-1
src/App.svelte
···
30
30
<main class="container mx-auto px-4 py-8 max-w-4xl">
31
31
<div class="text-center mb-8">
32
32
{#if showRepoStats}
33
-
<h2 class="text-2xl font-bold text-primary">Walking <a class="link link-info" href="https://pdsls.dev/at://{searchResults.did}" target="_blank">{searchResults.handle}</a>'s {searchResults.slowPoke ? 'via api calls' : 'via export'}</h2>
33
+
<h2 class="text-2xl font-bold text-primary">Walking <a class="link link-info" href="https://pdsls.dev/at://{searchResults.did}" target="_blank">{searchResults.handle}</a>'s repo {searchResults.slowPoke ? 'via api calls' : 'via export'}</h2>
34
34
{:else}
35
35
<h1 class="text-5xl font-bold mb-4">Walk The Repo</h1>
36
36
<p class="text-lg mb-2">Demo showing why you may rather export the users whole repo instead of walking it via api calls if you want to access all the user's records.</p>
+7
-7
src/lib/RepoStats.svelte
+7
-7
src/lib/RepoStats.svelte
···
2
2
import { onMount } from 'svelte';
3
3
import { Client, simpleFetchHandler } from '@atcute/client';
4
4
import type {} from '@atcute/atproto';
5
-
import { repoEntryTransform } from '@atcute/repo';
5
+
import { fromStream } from '@atcute/repo';
6
6
7
7
const { did, handle, pdsUrl, slowPokeMode } = $props();
8
8
···
65
65
if (!result.ok) {
66
66
throw new Error(`HTTP error! status: ${result.status}`);
67
67
}
68
-
69
-
const { readable, writable } = repoEntryTransform();
70
-
//Don't want to await so we can read as it streams
71
-
result.data.pipeTo(writable);
68
+
const repo = fromStream(result.data);
72
69
73
70
try {
74
71
//This reads the repo as it is downloaded. which was very cool and I didn't know it would do that
75
-
for await (const entry of readable) {
72
+
for await (const entry of repo) {
76
73
// record here is the content of the atproto record
77
74
// console.log(entry.record);
78
75
let checkForCollection = collections.find(c => c.collection === entry.collection);
···
90
87
loading = false;
91
88
} catch (err) {
92
89
stopTimer();
90
+
console.log(err);
93
91
console.error('Error fetching repo stats:', err);
94
92
if (err instanceof Error) {
95
93
error = err.message;
···
124
122
const firstCollectionList = await rpc.get('com.atproto.repo.listRecords', {
125
123
params: {
126
124
collection,
127
-
repo: did
125
+
repo: did,
126
+
limit: 100,
128
127
}
129
128
});
130
129
webCalls++;
···
142
141
params: {
143
142
collection,
144
143
repo: did,
144
+
limit: 100,
145
145
cursor
146
146
}
147
147
});