Skip to content

Commit

Permalink
Extraction: slow extraction option
Browse files Browse the repository at this point in the history
  • Loading branch information
joonaspaakko committed Jan 6, 2025
1 parent 25f34b7 commit a05e5ad
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/content-script/_components/_mixins/calls/amapxios.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export default {
amapxios: function(options) {

const vue = this;
const limiter = options.rateLimit || this.$store.state.axiosRateLimit;
const limiter = _.cloneDeep( options.rateLimit || this.$store.state.axiosRateLimit );
if ( vue.$store.state.sticky.slowExtract ) {
limiter.maxRequests = _.clamp( limiter.maxRequests * .5, 1, limiter.maxRequests );
}
const maxTimeout = this.minutesToMilliseconds(1);

// AXIOS
Expand Down Expand Up @@ -130,7 +133,10 @@ export default {
chunkAmapxios: function(options) {

const vue = this;
const limiter = options.rateLimit || this.$store.state.axiosRateLimit;
const limiter = _.cloneDeep( options.rateLimit || this.$store.state.axiosRateLimit );
if ( vue.$store.state.sticky.slowExtract ) {
limiter.maxRequests = _.clamp( limiter.maxRequests * .5, 1, limiter.maxRequests );
}
const maxTimeout = this.minutesToMilliseconds(1);

// AXIOS
Expand Down
5 changes: 4 additions & 1 deletion src/content-script/_components/_mixins/calls/scrapingPrep.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export default {
// }
// });
// const axiosLimited = rateLimit(letMeAxiosAQuestion, { maxRPS: 15 });
const axiosLimited = rateLimit(letMeAxiosAQuestion, this.$store.state.axiosRateLimit);

const limiter = _.cloneDeep(this.$store.state.axiosRateLimit);
limiter.maxRequests = _.clamp( limiter.maxRequests * .5, 1, limiter.maxRequests );
const axiosLimited = rateLimit(letMeAxiosAQuestion, limiter);

waterfall(
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
<input v-if="action.inputEvent" accept=".json" type="file" @change="clickEvent( action, $event )" style="display:none">
</label>
</button>
<button class="button is-small" @click="$store.commit('update', { key: 'sticky.slowExtract', value: !store.sticky.slowExtract })">
Extract&nbsp;<span v-if="store.sticky.slowExtract">slow</span> <span v-else>fast</span> &nbsp;
<mdi-speedometer-slow class="has-text-info" v-if="store.sticky.slowExtract"/>
<mdi-speedometer class="has-text-danger" v-else />
<!-- <mdi-snail class="has-text-info" v-if="store.sticky.slowExtract"/>
<mdi-rabbit class="has-text-danger" v-else /> -->
</button>
</div>

</div>
Expand Down Expand Up @@ -229,5 +236,14 @@ export default {
<style scoped src="@node/bulma/css/bulma.css"></style>

<style scoped lang="scss">
.button {
&, label {
display: inline-flex;
justify-content: center;
align-items: center;
}
svg {
font-size: 1.2em;
}
}
</style>
1 change: 1 addition & 0 deletions src/content-script/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export default createStore({
kind: 'extra',
}
],
slowExtract: false,
},
},

Expand Down

0 comments on commit a05e5ad

Please sign in to comment.