Skip to content
Permalink
Browse files

Removed 250ms retry from TV API calls

  • Loading branch information...
Chris Turk
Chris Turk committed Feb 28, 2019
1 parent ffe9e4c commit 1c4bbd24ed6e8f26c3ab5fd535f9d561d1bde4b8
Showing with 17 additions and 4 deletions.
  1. +16 −3 background/reviews.js
  2. +1 −1 mturk/turkerview/return-reviews.js
@@ -30,6 +30,18 @@ const fetchNeverFail = (url, options) =>
fetchURL();
});

const fetchOrFail = (url, options) =>
new Promise((resolve) => {
const fetchURL = () =>
fetch(url, options)
.then((response) => resolve(response))
.catch(() => {
//let it go
});

fetchURL();
});

const fetchTurkerview = async (rids) => {
const storage = await new Promise((resolve) => chrome.storage.local.get([`options`], resolve));

@@ -39,7 +51,7 @@ const fetchTurkerview = async (rids) => {
[`X-APP-VER`, chrome.runtime.getManifest().version],
]);

return fetchNeverFail(`https://view.turkerview.com/v1/requesters/?requester_ids=${rids}`, { headers });
return fetchOrFail(`https://view.turkerview.com/v1/requesters/?requester_ids=${rids}`, { headers });
};
const fetchTurkopticon = (rids) => fetchNeverFail(`https://turkopticon.ucsd.edu/api/multi-attrs.php?ids=${rids}`);

@@ -131,8 +143,9 @@ const handleDelete = (name) =>
new Promise(async (resolve) => {
const { db } = REVIEWS[name];
const transaction = db.transaction([`requester`], `readwrite`);
transaction.deleteObjectStore(`requester`);
transaction.oncomplete = resolve;
const objectStore = transaction.objectStore(`requester`);
const objectStoreRequest = objectStore.clear();
objectStoreRequest.onsuccess = resolve;
});

const handleTurkerview = () =>
@@ -137,7 +137,7 @@ const classMap = total_reports => total_reports == 0 ? 'text-muted' :
total_reports < 3 ? 'text-warning' : 'text-danger';

function buildReturnWarnings(json){
if (json['broken_total'] + json['underpaid_total'] + json['unpaid_screener_total'] + json['tos_total'] + json['writing_total'] + json['inquisit_total'] == 0) return;
if (json['broken_total'] + json['underpaid_total'] + json['unpaid_screener_total'] + json['tos_total'] + json['writing_total'] + json['downloads_total'] == 0) return;

let highest_warning_class = 'text-danger';
let x = Number(json['broken_total']) + Number(json['underpaid_total']) + Number(json['unpaid_screener_total']) + Number(json['tos_total']) + Number(json['writing_total']) + Number(json['downloads_total']);

0 comments on commit 1c4bbd2

Please sign in to comment.
You can’t perform that action at this time.