Skip to content

Commit

Permalink
rm compress flag add limit flag bump report table version
Browse files Browse the repository at this point in the history
  • Loading branch information
secondl1ght committed Jan 21, 2024
1 parent 03f78f6 commit ce2f75f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/lib/sync/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ const limit = 20000;

export const reportsSync = async () => {
// clear tables if present
clearTables(['reports', 'reports_v2', 'reports_v3']);
clearTables(['reports', 'reports_v2', 'reports_v3', 'reports_v4']);

// get reports from local
await localforage
.getItem<Report[]>('reports_v4')
.getItem<Report[]>('reports_v5')
.then(async function (value) {
// get reports from API if initial sync
if (!value) {
Expand All @@ -26,7 +26,7 @@ export const reportsSync = async () => {
do {
try {
const response = await axios.get<Report[]>(
`https://api.btcmap.org/v2/reports?updated_since=${updatedSince}&compress=true`
`https://api.btcmap.org/v2/reports?updated_since=${updatedSince}&limit=${limit}`
);

updatedSince = response.data[response.data.length - 1]['updated_at'];
Expand All @@ -51,7 +51,7 @@ export const reportsSync = async () => {

// set response to local
localforage
.setItem('reports_v4', reportsData)
.setItem('reports_v5', reportsData)
.then(function () {
// set response to store
reports.set(reportsFiltered);
Expand Down Expand Up @@ -81,7 +81,7 @@ export const reportsSync = async () => {
do {
try {
const response = await axios.get<Report[]>(
`https://api.btcmap.org/v2/reports?updated_since=${updatedSince}&compress=true`
`https://api.btcmap.org/v2/reports?updated_since=${updatedSince}&limit=${limit}`
);

// update new records if they exist
Expand Down Expand Up @@ -130,7 +130,7 @@ export const reportsSync = async () => {

// set updated reports locally
localforage
.setItem('reports_v4', reportsData)
.setItem('reports_v5', reportsData)
.then(function () {
// set updated reports to store
reports.set(newReportsFiltered);
Expand Down Expand Up @@ -159,7 +159,7 @@ export const reportsSync = async () => {
do {
try {
const response = await axios.get<Report[]>(
`https://api.btcmap.org/v2/reports?updated_since=${updatedSince}&compress=true`
`https://api.btcmap.org/v2/reports?updated_since=${updatedSince}&limit=${limit}`
);

updatedSince = response.data[response.data.length - 1]['updated_at'];
Expand Down

0 comments on commit ce2f75f

Please sign in to comment.