enh
This commit is contained in:
parent
524acbd1a6
commit
ac0750733f
8 changed files with 155 additions and 67 deletions
6
apps/admin-ui/.expo/types/router.d.ts
vendored
6
apps/admin-ui/.expo/types/router.d.ts
vendored
File diff suppressed because one or more lines are too long
|
|
@ -17,10 +17,11 @@ import jwt from 'jsonwebtoken'
|
||||||
import signedUrlCache from 'src/lib/signed-url-cache';
|
import signedUrlCache from 'src/lib/signed-url-cache';
|
||||||
import { seed } from 'src/db/seed';
|
import { seed } from 'src/db/seed';
|
||||||
import './src/jobs/jobs-index';
|
import './src/jobs/jobs-index';
|
||||||
|
import { startAutomatedJobs } from './src/lib/automatedJobs';
|
||||||
|
|
||||||
seed()
|
seed()
|
||||||
initFunc()
|
initFunc()
|
||||||
|
startAutomatedJobs()
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
|
|
||||||
83
apps/backend/src/lib/automatedJobs.ts
Normal file
83
apps/backend/src/lib/automatedJobs.ts
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
import * as cron from 'node-cron';
|
||||||
|
import { db } from '../db/db_index';
|
||||||
|
import { productInfo, keyValStore } from '../db/schema';
|
||||||
|
import { inArray, eq } from 'drizzle-orm';
|
||||||
|
import { CONST_KEYS } from '../lib/const-keys';
|
||||||
|
import { computeConstants } from '../lib/const-store';
|
||||||
|
|
||||||
|
|
||||||
|
const MUTTON_ITEMS = [
|
||||||
|
12, //Lamb mutton
|
||||||
|
14, // Mutton Boti
|
||||||
|
35, //Mutton Kheema
|
||||||
|
84, //Mutton Brain
|
||||||
|
4, //Mutton
|
||||||
|
86, //Mutton Chops
|
||||||
|
87, //Mutton Soup bones
|
||||||
|
85 //Mutton paya
|
||||||
|
];
|
||||||
|
|
||||||
|
export const startAutomatedJobs = () => {
|
||||||
|
// Job to disable flash delivery for mutton at 12 PM daily
|
||||||
|
cron.schedule('0 12 * * *', async () => {
|
||||||
|
try {
|
||||||
|
console.log('Disabling flash delivery for products at 12 PM');
|
||||||
|
await db
|
||||||
|
.update(productInfo)
|
||||||
|
.set({ isFlashAvailable: false })
|
||||||
|
.where(inArray(productInfo.id, MUTTON_ITEMS));
|
||||||
|
console.log('Flash delivery disabled successfully');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error disabling flash delivery:', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Job to enable flash delivery for mutton at 6 AM daily
|
||||||
|
cron.schedule('0 6 * * *', async () => {
|
||||||
|
try {
|
||||||
|
console.log('Enabling flash delivery for products at 5 AM');
|
||||||
|
await db
|
||||||
|
.update(productInfo)
|
||||||
|
.set({ isFlashAvailable: true })
|
||||||
|
.where(inArray(productInfo.id, MUTTON_ITEMS));
|
||||||
|
console.log('Flash delivery enabled successfully');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error enabling flash delivery:', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Job to disable flash delivery feature at 9 PM daily
|
||||||
|
cron.schedule('0 21 * * *', async () => {
|
||||||
|
try {
|
||||||
|
console.log('Disabling flash delivery feature at 9 PM');
|
||||||
|
await db
|
||||||
|
.update(keyValStore)
|
||||||
|
.set({ value: false })
|
||||||
|
.where(eq(keyValStore.key, CONST_KEYS.isFlashDeliveryEnabled));
|
||||||
|
await computeConstants(); // Refresh Redis cache
|
||||||
|
console.log('Flash delivery feature disabled successfully');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error disabling flash delivery feature:', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Job to enable flash delivery feature at 6 AM daily
|
||||||
|
cron.schedule('0 6 * * *', async () => {
|
||||||
|
try {
|
||||||
|
console.log('Enabling flash delivery feature at 6 AM');
|
||||||
|
await db
|
||||||
|
.update(keyValStore)
|
||||||
|
.set({ value: true })
|
||||||
|
.where(eq(keyValStore.key, CONST_KEYS.isFlashDeliveryEnabled));
|
||||||
|
await computeConstants(); // Refresh Redis cache
|
||||||
|
console.log('Flash delivery feature enabled successfully');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error enabling flash delivery feature:', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('Automated jobs scheduled');
|
||||||
|
};
|
||||||
|
|
||||||
|
// Optional: Call on import if desired, or export and call in main app
|
||||||
|
// startAutomatedJobs();
|
||||||
8
apps/fallback-ui/.expo/README.md
Normal file
8
apps/fallback-ui/.expo/README.md
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
> Why do I have a folder named ".expo" in my project?
|
||||||
|
The ".expo" folder is created when an Expo project is started using "expo start" command.
|
||||||
|
> What do the files contain?
|
||||||
|
- "devices.json": contains information about devices that have recently opened this project. This is used to populate the "Development sessions" list in your development builds.
|
||||||
|
- "settings.json": contains the server configuration that is used to serve the application manifest.
|
||||||
|
> Should I commit the ".expo" folder?
|
||||||
|
No, you should not share the ".expo" folder. It does not contain any information that is relevant for other developers working on the project, it is specific to your machine.
|
||||||
|
Upon project creation, the ".expo" folder is already added to your ".gitignore" file.
|
||||||
3
apps/fallback-ui/.expo/devices.json
Normal file
3
apps/fallback-ui/.expo/devices.json
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"devices": []
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,11 @@
|
||||||
"target": "ES2022",
|
"target": "ES2022",
|
||||||
"useDefineForClassFields": true,
|
"useDefineForClassFields": true,
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
"lib": [
|
||||||
|
"DOM",
|
||||||
|
"DOM.Iterable",
|
||||||
|
"ESNext"
|
||||||
|
],
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"moduleResolution": "Bundler",
|
"moduleResolution": "Bundler",
|
||||||
"allowImportingTsExtensions": false,
|
"allowImportingTsExtensions": false,
|
||||||
|
|
@ -17,12 +21,24 @@
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./src/*"],
|
"@/*": [
|
||||||
// "common-ui/shared-types": ["../../packages/ui/shared-types"]
|
"./src/*"
|
||||||
"common-ui": ["../../packages/ui"],
|
],
|
||||||
"common-ui/*": ["../../packages/ui/*"]
|
"common-ui": [
|
||||||
|
"../../packages/ui"
|
||||||
|
],
|
||||||
|
"common-ui/*": [
|
||||||
|
"../../packages/ui/*"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"types": ["node"]
|
"types": [
|
||||||
|
"node"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"include": ["./src", "./vite.config.ts", "./env.d.ts"]
|
"include": [
|
||||||
|
"./src",
|
||||||
|
"./vite.config.ts",
|
||||||
|
"./env.d.ts"
|
||||||
|
],
|
||||||
|
"extends": "expo/tsconfig.base"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ export default function Layout() {
|
||||||
>
|
>
|
||||||
<Ionicons name="flash" size={28} color="white" />
|
<Ionicons name="flash" size={28} color="white" />
|
||||||
</LinearGradient>
|
</LinearGradient>
|
||||||
<MyText numberOfLines={1} style={tw`text-[10px] font-bold text-brand600 mt-0.5`}>Flash Delivery</MyText>
|
<MyText numberOfLines={1} style={tw`text-[10px] font-bold mt-0.5 ${props.accessibilityState?.selected ? 'text-brand600' : 'text-gray-500'}`}>Flash Delivery</MyText>
|
||||||
</View>
|
</View>
|
||||||
</MyTouchableOpacity>
|
</MyTouchableOpacity>
|
||||||
),
|
),
|
||||||
|
|
|
||||||
81
package-lock.json
generated
81
package-lock.json
generated
|
|
@ -12792,9 +12792,9 @@
|
||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0"
|
||||||
},
|
},
|
||||||
"node_modules/diff": {
|
"node_modules/diff": {
|
||||||
"version": "4.0.2",
|
"version": "4.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.4.tgz",
|
||||||
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
|
"integrity": "sha512-X07nttJQkwkfKfvTPG/KSnE2OMdcUCao6+eXF3wmnIQRn2aPAHH3VxDbDOdegkd6JbPsXqShpvEOHfAT+nCNwQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|
@ -17474,15 +17474,15 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/lodash": {
|
"node_modules/lodash": {
|
||||||
"version": "4.17.21",
|
"version": "4.17.23",
|
||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz",
|
||||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
"integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/lodash-es": {
|
"node_modules/lodash-es": {
|
||||||
"version": "4.17.21",
|
"version": "4.17.23",
|
||||||
"resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz",
|
"resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.23.tgz",
|
||||||
"integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==",
|
"integrity": "sha512-kVI48u3PZr38HdYz98UmfPnXl2DXrpdctLrFLCd3kOx1xUkOmpFPx7gCWWM5MPkL/fD8zb+Ph0QzjGFs4+hHWg==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/lodash.debounce": {
|
"node_modules/lodash.debounce": {
|
||||||
|
|
@ -19740,9 +19740,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/qs": {
|
"node_modules/qs": {
|
||||||
"version": "6.14.0",
|
"version": "6.14.1",
|
||||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz",
|
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.1.tgz",
|
||||||
"integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==",
|
"integrity": "sha512-4EK3+xJl8Ts67nLYNwqw/dsFVnCf+qR7RgXSK9jEEm9unao3njwMDdmsdvoKBKHzxd7tCYz5e5M+SnMjdtXGQQ==",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"side-channel": "^1.1.0"
|
"side-channel": "^1.1.0"
|
||||||
|
|
@ -21133,18 +21133,18 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/seroval": {
|
"node_modules/seroval": {
|
||||||
"version": "1.4.0",
|
"version": "1.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/seroval/-/seroval-1.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/seroval/-/seroval-1.5.0.tgz",
|
||||||
"integrity": "sha512-BdrNXdzlofomLTiRnwJTSEAaGKyHHZkbMXIywOh7zlzp4uZnXErEwl9XZ+N1hJSNpeTtNxWvVwN0wUzAIQ4Hpg==",
|
"integrity": "sha512-OE4cvmJ1uSPrKorFIH9/w/Qwuvi/IMcGbv5RKgcJ/zjA/IohDLU6SVaxFN9FwajbP7nsX0dQqMDes1whk3y+yw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/seroval-plugins": {
|
"node_modules/seroval-plugins": {
|
||||||
"version": "1.4.0",
|
"version": "1.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/seroval-plugins/-/seroval-plugins-1.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/seroval-plugins/-/seroval-plugins-1.5.0.tgz",
|
||||||
"integrity": "sha512-zir1aWzoiax6pbBVjoYVd0O1QQXgIL3eVGBMsBsNmM8Ukq90yGaWlfx0AB9dTS8GPqrOrbXn79vmItCUP9U3BQ==",
|
"integrity": "sha512-EAHqADIQondwRZIdeW2I636zgsODzoBDwb3PT/+7TLDWyw1Dy/Xv7iGUIEXXav7usHDE9HVhOU61irI3EnyyHA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
|
|
@ -21499,38 +21499,15 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/solid-js": {
|
"node_modules/solid-js": {
|
||||||
"version": "1.9.10",
|
"version": "1.9.11",
|
||||||
"resolved": "https://registry.npmjs.org/solid-js/-/solid-js-1.9.10.tgz",
|
"resolved": "https://registry.npmjs.org/solid-js/-/solid-js-1.9.11.tgz",
|
||||||
"integrity": "sha512-Coz956cos/EPDlhs6+jsdTxKuJDPT7B5SVIWgABwROyxjY7Xbr8wkzD68Et+NxnV7DLJ3nJdAC2r9InuV/4Jew==",
|
"integrity": "sha512-WEJtcc5mkh/BnHA6Yrg4whlF8g6QwpmXXRg4P2ztPmcKeHHlH4+djYecBLhSpecZY2RRECXYUwIc/C2r3yzQ4Q==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"csstype": "^3.1.0",
|
"csstype": "^3.1.0",
|
||||||
"seroval": "~1.3.0",
|
"seroval": "~1.5.0",
|
||||||
"seroval-plugins": "~1.3.0"
|
"seroval-plugins": "~1.5.0"
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/solid-js/node_modules/seroval": {
|
|
||||||
"version": "1.3.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/seroval/-/seroval-1.3.2.tgz",
|
|
||||||
"integrity": "sha512-RbcPH1n5cfwKrru7v7+zrZvjLurgHhGyso3HTyGtRivGWgYjbOmGuivCQaORNELjNONoK35nj28EoWul9sb1zQ==",
|
|
||||||
"license": "MIT",
|
|
||||||
"peer": true,
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/solid-js/node_modules/seroval-plugins": {
|
|
||||||
"version": "1.3.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/seroval-plugins/-/seroval-plugins-1.3.3.tgz",
|
|
||||||
"integrity": "sha512-16OL3NnUBw8JG1jBLUoZJsLnQq0n5Ua6aHalhJK4fMQkz1lqR7Osz1sA30trBtd9VUDc2NgkuRCn8+/pBwqZ+w==",
|
|
||||||
"license": "MIT",
|
|
||||||
"peer": true,
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"seroval": "^1.0"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/source-map": {
|
"node_modules/source-map": {
|
||||||
|
|
@ -22096,9 +22073,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tar": {
|
"node_modules/tar": {
|
||||||
"version": "7.5.2",
|
"version": "7.5.6",
|
||||||
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.2.tgz",
|
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.6.tgz",
|
||||||
"integrity": "sha512-7NyxrTE4Anh8km8iEy7o0QYPs+0JKBTj5ZaqHg6B39erLg0qYXN3BijtShwbsNSvQ+LN75+KV+C4QR/f6Gwnpg==",
|
"integrity": "sha512-xqUeu2JAIJpXyvskvU3uvQW8PAmHrtXp2KDuMJwQqW8Sqq0CaZBAQ+dKS3RBXVhU4wC5NjAdKrmh84241gO9cA==",
|
||||||
"license": "BlueOak-1.0.0",
|
"license": "BlueOak-1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@isaacs/fs-minipass": "^4.0.0",
|
"@isaacs/fs-minipass": "^4.0.0",
|
||||||
|
|
@ -23425,9 +23402,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici": {
|
"node_modules/undici": {
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-6.22.0.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-6.23.0.tgz",
|
||||||
"integrity": "sha512-hU/10obOIu62MGYjdskASR3CUAiYaFTtC9Pa6vHyf//mAipSvSQg6od2CnJswq7fvzNS3zJhxoRkgNVaHurWKw==",
|
"integrity": "sha512-VfQPToRA5FZs/qJxLIinmU59u0r7LXqoJkCzinq3ckNJp3vKEh7jTWN589YQ5+aoAC/TGRLyJLCPKcLQbM8r9g==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.17"
|
"node": ">=18.17"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue