@@ -5,7 +5,6 @@ import ImageModel from "../Database/Models/Images.model";
5
5
import OrderModel from "../Database/Models/Orders.model" ;
6
6
import ProductModel from "../Database/Models/Products.model" ;
7
7
import TransactionsModel from "../Database/Models/Transactions.model" ;
8
- import { Logger } from "lib" ;
9
8
import { CacheAdmin } from "./Admin.cache" ;
10
9
import { CacheCategories } from "./Categories.cache" ;
11
10
import { CacheCustomer } from "./Customer.cache" ;
@@ -16,19 +15,22 @@ import InvoiceModel from "../Database/Models/Invoices.model";
16
15
import { CacheInvoice } from "./Invoices.cache" ;
17
16
import { Company_Currency } from "../Config" ;
18
17
import { TPaymentCurrency } from "interfaces/types/Currencies" ;
18
+ import Logger from "@cpg/logger" ;
19
+
20
+ const log = new Logger ( "cpg:api:cache:reCache" ) ;
19
21
20
22
/**
21
23
* @deprecated
22
24
*/
23
25
export function reCache_Categories ( )
24
26
{
25
- Logger . info ( `Starting caching on categories..` ) ;
27
+ log . info ( `Starting caching on categories..` ) ;
26
28
return new Promise ( async ( resolve ) =>
27
29
{
28
30
const categories = await CategoryModel . find ( ) ;
29
31
for ( const c of categories )
30
32
{
31
- Logger . cache ( `Caching category ${ c . uid } ` ) ;
33
+ log . debug ( `Caching category ${ c . uid } ` ) ;
32
34
CacheCategories . set ( c . uid , c ) ;
33
35
}
34
36
return resolve ( true ) ;
@@ -37,13 +39,13 @@ export function reCache_Categories()
37
39
38
40
export async function reCache_Admin ( )
39
41
{
40
- Logger . info ( `Starting caching on admins..` ) ;
42
+ log . info ( `Starting caching on admins..` ) ;
41
43
return new Promise ( async ( resolve ) =>
42
44
{
43
45
const admin = await AdminModel . find ( ) ;
44
46
for ( const a of admin )
45
47
{
46
- Logger . cache ( `Caching admin ${ a . uid } ` ) ;
48
+ log . debug ( `Caching admin ${ a . uid } ` ) ;
47
49
CacheAdmin . set ( a . uid , a ) ;
48
50
}
49
51
return resolve ( true ) ;
@@ -52,7 +54,7 @@ export async function reCache_Admin()
52
54
53
55
export async function reCache_Customers ( )
54
56
{
55
- Logger . info ( `Starting caching on customers..` ) ;
57
+ log . info ( `Starting caching on customers..` ) ;
56
58
return new Promise ( async ( resolve ) =>
57
59
{
58
60
const customer = await CustomerModel . find ( ) ;
@@ -65,7 +67,7 @@ export async function reCache_Customers()
65
67
c . currency = companyCurrency . toLocaleUpperCase ( ) as TPaymentCurrency ;
66
68
await c . save ( ) ;
67
69
}
68
- // Logger .cache(`Caching customer ${c.uid}`);
70
+ // log .cache(`Caching customer ${c.uid}`);
69
71
CacheCustomer . set ( c . uid , c ) ;
70
72
}
71
73
return resolve ( true ) ;
@@ -74,7 +76,7 @@ export async function reCache_Customers()
74
76
75
77
export async function reCache_Product ( )
76
78
{
77
- Logger . info ( `Starting caching on products..` ) ;
79
+ log . info ( `Starting caching on products..` ) ;
78
80
return new Promise ( async ( resolve ) =>
79
81
{
80
82
const product = await ProductModel . find ( ) ;
@@ -100,7 +102,7 @@ export async function reCache_Product()
100
102
101
103
export async function reCache_Transactions ( )
102
104
{
103
- Logger . info ( `Starting caching on transactions..` ) ;
105
+ log . info ( `Starting caching on transactions..` ) ;
104
106
return new Promise ( async ( resolve ) =>
105
107
{
106
108
const transactions = await TransactionsModel . find ( ) ;
@@ -124,7 +126,7 @@ export async function reCache_Transactions()
124
126
125
127
export async function reCache_Orders ( )
126
128
{
127
- Logger . info ( `Starting caching on orders..` ) ;
129
+ log . info ( `Starting caching on orders..` ) ;
128
130
return new Promise ( async ( resolve ) =>
129
131
{
130
132
const order = await OrderModel . find ( ) ;
@@ -143,11 +145,11 @@ export async function reCache_Orders()
143
145
144
146
export async function reCache_Configs ( )
145
147
{
146
- Logger . info ( `Starting caching on configs..` ) ;
148
+ log . info ( `Starting caching on configs..` ) ;
147
149
return new Promise ( async ( resolve ) =>
148
150
{
149
151
const config = await ConfigModel . find ( ) ;
150
- // Logger .debug(config);
152
+ // log .debug(config);
151
153
if ( ! config [ 0 ] )
152
154
{
153
155
const smtpData = {
@@ -162,15 +164,15 @@ export async function reCache_Configs()
162
164
}
163
165
await new ConfigModel ( smtpData ) . save ( ) ;
164
166
165
- Logger . cache ( `Caching config` ) ;
167
+ log . debug ( `Caching config` ) ;
166
168
167
169
CacheConfig . set ( "smtp" , smtpData . smtp ) ;
168
170
CacheConfig . set ( "smtp_emails" , smtpData . smtp_emails ) ;
169
171
170
172
return resolve ( true ) ;
171
173
}
172
174
173
- Logger . cache ( `Caching config` ) ;
175
+ log . debug ( `Caching config` ) ;
174
176
const c = config [ 0 ] ;
175
177
176
178
// Check if c has payment_methods
@@ -199,13 +201,13 @@ export async function reCache_Configs()
199
201
200
202
export async function reCache_Images ( )
201
203
{
202
- Logger . info ( `Starting caching on images..` ) ;
204
+ log . info ( `Starting caching on images..` ) ;
203
205
return new Promise ( async ( resolve ) =>
204
206
{
205
207
const image = await ImageModel . find ( ) ;
206
208
for ( const o of image )
207
209
{
208
- Logger . cache ( `Caching image ${ o . id } ` ) ;
210
+ log . debug ( `Caching image ${ o . id } ` ) ;
209
211
CacheImages . set ( o . id , o ) ;
210
212
}
211
213
return resolve ( true ) ;
@@ -215,7 +217,7 @@ export async function reCache_Images()
215
217
216
218
export async function reCache_Invoices ( )
217
219
{
218
- Logger . info ( `Starting caching on invoices..` ) ;
220
+ log . info ( `Starting caching on invoices..` ) ;
219
221
return new Promise ( async ( resolve ) =>
220
222
{
221
223
const invoice = await InvoiceModel . find ( ) ;
@@ -243,7 +245,7 @@ export async function reCache_Invoices()
243
245
await o . save ( ) ;
244
246
}
245
247
246
- Logger . cache ( `Caching invoice ${ o . uid } ` ) ;
248
+ log . debug ( `Caching invoice ${ o . uid } ` ) ;
247
249
CacheInvoice . set ( o . uid , o ) ;
248
250
}
249
251
return resolve ( true ) ;
0 commit comments