mirror of
https://fast.feibisi.com/https://github.com/parcelvoy/platform.git
synced 2025-09-01 12:26:08 +08:00
Misc Performance Improvements (#105)
* Improves indexes Increases batch size * Fixes migration
This commit is contained in:
parent
a273247809
commit
16e58a248c
5 changed files with 32 additions and 12 deletions
|
@ -0,0 +1,17 @@
|
|||
exports.up = async function(knex) {
|
||||
await knex.schema
|
||||
.alterTable('users', function(table) {
|
||||
table.index('external_id')
|
||||
table.index('anonymous_id')
|
||||
table.index('project_id')
|
||||
})
|
||||
}
|
||||
|
||||
exports.down = async function(knex) {
|
||||
await knex.schema
|
||||
.alterTable('users', function(table) {
|
||||
table.dropIndex('external_id')
|
||||
table.dropIndex('anonymous_id')
|
||||
table.dropIndex('project_id')
|
||||
})
|
||||
}
|
|
@ -58,9 +58,9 @@ export default class RedisQueueProvider implements QueueProvider {
|
|||
start(): void {
|
||||
this.worker = new Worker('parcelvoy', async job => {
|
||||
await this.queue.dequeue(job.data)
|
||||
}, { connection: this.config, concurrency: 25 })
|
||||
}, { connection: this.config, concurrency: this.batchSize })
|
||||
this.worker.on('failed', (job, error) => {
|
||||
logger.error({ error }, 'sqs:error:processing')
|
||||
logger.error({ error }, 'redis:error:processing')
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -3,23 +3,26 @@ import { loadAnalytics } from '../providers/analytics'
|
|||
import { User } from '../users/User'
|
||||
import { UserEvent, UserEventParams } from './UserEvent'
|
||||
|
||||
export const createEvent = async (user: User, event: UserEventParams): Promise<number> => {
|
||||
export const createEvent = async (user: User, event: UserEventParams, forward = true): Promise<number> => {
|
||||
const data = {
|
||||
project_id: user.project_id,
|
||||
user_id: user.id,
|
||||
...event,
|
||||
}
|
||||
const id = await UserEvent.insert(data)
|
||||
const analytics = await loadAnalytics(user.project_id)
|
||||
analytics.track({
|
||||
external_id: user.external_id,
|
||||
...event,
|
||||
})
|
||||
|
||||
if (forward) {
|
||||
const analytics = await loadAnalytics(user.project_id)
|
||||
analytics.track({
|
||||
external_id: user.external_id,
|
||||
...event,
|
||||
})
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
export const createAndFetchEvent = async (user: User, event: UserEventParams): Promise<UserEvent> => {
|
||||
const id = await createEvent(user, event)
|
||||
export const createAndFetchEvent = async (user: User, event: UserEventParams, forward = false): Promise<UserEvent> => {
|
||||
const id = await createEvent(user, event, forward)
|
||||
const userEvent = await UserEvent.find(id)
|
||||
return userEvent!
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ export function SearchTable<T extends Record<string, any>>({
|
|||
}
|
||||
{
|
||||
filters.length > 0 && (
|
||||
<Stack style={{ paddingBottom: 15 }}>
|
||||
<Stack>
|
||||
{filters}
|
||||
</Stack>
|
||||
)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: var(--spacing);
|
||||
padding-bottom: var(--spacing);
|
||||
margin-bottom: var(--spacing);
|
||||
}
|
||||
|
||||
.ui-stack.ui-stack-vertical {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue