Comments (7)
Insert to credits_additions
may happen even when associated users are not registered. Since they don't have userId
it is not possible create a row in credits
for them. That means users can't get credits for their donations/adoptions before they are registered on dashboard.
I can add a e.g. consumed: false
column to credits_additions
and set it to true
only if value was added to credits
. Then, on user sign up it is possible to go through all additions and give them all their prev credits.
from globalping.
That seems nice, sure. So when you start sponsoring and register only sometime later, you'll get all the credits.
from globalping.
Should X-RateLimit-Limit
return values as previously? Or include available credits data?
from globalping.
Existing headers as before and this:
When credits are involved in handling the request, it would be good to also add two new headers: X-Credits-Remaining and X-Credits-Cost
from globalping.
Oh, missed that description part.
X-Credits-Cost
is how much credits where deducted during that request?- seems like a second sql request is required to support
X-Credits-Remaining
, as update only returns number of affected rows:
await this.sql(CREDITS_TABLE).where({ user_id: userId }).update({ amount: this.sql.raw('amount - ?', [ credits ]) });
const remaining = await this.sql(CREDITS_TABLE).where({ user_id: userId }).select('amount');
there is an option to add add .returning('amount');
, but that requires Postgresql.
const remaining = await this.sql(CREDITS_TABLE).where({ user_id: userId }).update({ amount: this.sql.raw('amount - ?', [ credits ]) }).returning('amount');
from globalping.
Should be possible with our DB too now: https://mariadb.com/kb/en/insertreturning/
Maybe will need a raw query if knex doesn't know it yet.
from globalping.
We need to update gp_credits
instead of inserting. Since there is no UPDATE...RETURNING it still looks doable with INSERT INTO ... ON DUPLICATE KEY UPDATE ... RETURNING
, where insert does nothing (amount: 0
) and subtraction logic is inside ON DUPLICATE KEY UPDATE
.
from globalping.
Related Issues (20)
- Issue
- Question about http(s) measurements. HOT 2
- proposed solution for #447 HOT 3
- Add extra TLS data HOT 1
- Add a periodic check for "1 probe per IP" rule
- Allow DNS requests for TLDs and root zone HOT 2
- Improve locations selection
- Upgrade TS and related dependencies
- Add support IPv6 for actions runner HOT 1
- Exclude client errors from APM reporting
- Add IPv6 e2e tests
- Rate limits for GET HOT 1
- Multi IP handling HOT 8
- Push app names to new relic
- IPv auto selection
- Always send X-Credits-Required on 429 errors
- Add token support to demo page
- Creating a measurement using Globalping API with HttpOptions is not successful HOT 3
- Check random e2e failures HOT 1
- Support IP ranges whitelist
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from globalping.