@xuda.io/account_module 1.2.1574 → 1.2.1576
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +15 -1
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1918,7 +1918,7 @@ setTimeout(async () => {
|
|
|
1918
1918
|
// console.log(_design.views.ai_chat_usage);
|
|
1919
1919
|
// ret = await set_contact_profile_picture(uid, 'cnt_2d21d55f8f0cdaf65a7a69f69617f532', {}, null, {});
|
|
1920
1920
|
// ret = await get_picture_cache(uid, 'chat_thumbnail', 'word five title');
|
|
1921
|
-
add_ai_credits_to_active_accounts();
|
|
1921
|
+
// add_ai_credits_to_active_accounts();
|
|
1922
1922
|
console.log(ret);
|
|
1923
1923
|
}, 1000);
|
|
1924
1924
|
|
|
@@ -3132,3 +3132,17 @@ export const add_ai_credits_to_active_accounts = async function () {
|
|
|
3132
3132
|
}
|
|
3133
3133
|
}
|
|
3134
3134
|
};
|
|
3135
|
+
|
|
3136
|
+
export const run_to_expire_ai_credits = async function () {
|
|
3137
|
+
const _24_hr_ms = 1000 * 60 * 60 * 24;
|
|
3138
|
+
const _mo_ms = _24_hr_ms * 30;
|
|
3139
|
+
const active_accounts = await db_module.find_couch_query('xuda_accounts', { selector: { stat: 3, docType: 'account', last_free_daily_ai_credit_ts: { $lt: Date.now() - _24_hr_ms }, membership_plan: 'free' }, limit: 99999 });
|
|
3140
|
+
for await (let account_doc of active_accounts.docs) {
|
|
3141
|
+
const ret = await record_ai_credit('system', 1, 'daily credit', 'free daily credit ' + date_str, account_doc._id);
|
|
3142
|
+
if (ret.code > -1) {
|
|
3143
|
+
account_doc.last_free_daily_ai_credit_ts = Date.now();
|
|
3144
|
+
account_doc.last_free_daily_ai_credit_id = ret.data.id;
|
|
3145
|
+
const save_ret = await db_module.save_couch_doc('xuda_accounts', account_doc);
|
|
3146
|
+
}
|
|
3147
|
+
}
|
|
3148
|
+
};
|