Conversation
| ranking: number; | ||
|
|
||
| @Column({ type: 'text', nullable: true }) | ||
| @Index('IDX_dataset_location_externalId') |
There was a problem hiding this comment.
Added index since we are now querying it on profile save
|
🍹 The Update (preview) for dailydotdev/api/prod (at f1f1732) was successful. Resource Changes Name Type Operation
~ vpc-native-validate-active-users-cron kubernetes:batch/v1:CronJob update
~ vpc-native-generic-referral-reminder-cron kubernetes:batch/v1:CronJob update
~ vpc-native-personalized-digest-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-update-source-tag-view-cron kubernetes:batch/v1:CronJob update
~ vpc-native-post-analytics-clickhouse-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-trending-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-tag-recommendations-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-stale-user-transactions-cron kubernetes:batch/v1:CronJob update
- vpc-native-api-db-migration-ce7d5dd7 kubernetes:batch/v1:Job delete
+ vpc-native-api-db-migration-cfb95f72 kubernetes:batch/v1:Job create
~ vpc-native-update-tags-str-cron kubernetes:batch/v1:CronJob update
~ vpc-native-hourly-notification-cron kubernetes:batch/v1:CronJob update
~ vpc-native-check-analytics-report-cron kubernetes:batch/v1:CronJob update
~ vpc-native-daily-digest-cron kubernetes:batch/v1:CronJob update
~ vpc-native-private-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-clean-zombie-images-cron kubernetes:batch/v1:CronJob update
~ vpc-native-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-clean-gifted-plus-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-source-public-threshold-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-zombie-users-cron kubernetes:batch/v1:CronJob update
- vpc-native-api-clickhouse-migration-ce7d5dd7 kubernetes:batch/v1:Job delete
~ vpc-native-calculate-top-readers-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-zombie-user-companies-cron kubernetes:batch/v1:CronJob update
~ vpc-native-generate-search-invites-cron kubernetes:batch/v1:CronJob update
~ vpc-native-temporal-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-sync-subscription-with-cio-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-highlighted-views-cron kubernetes:batch/v1:CronJob update
~ vpc-native-post-analytics-history-day-clickhouse-cron kubernetes:batch/v1:CronJob update
+ vpc-native-api-clickhouse-migration-cfb95f72 kubernetes:batch/v1:Job create
~ vpc-native-update-views-cron kubernetes:batch/v1:CronJob update
~ vpc-native-ws-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-personalized-digest-cron kubernetes:batch/v1:CronJob update
~ vpc-native-bg-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-update-current-streak-cron kubernetes:batch/v1:CronJob update
+- vpc-native-k8s-secret kubernetes:core/v1:Secret create-replacement
|
| let mapboxGeocodingUrl = `${process.env.MAPBOX_GEOCODING_URL}?q=${encodeURIComponent(externalId)}&access_token=${process.env.MAPBOX_ACCESS_TOKEN}`; | ||
|
|
||
| if (process.env.NODE_ENV === 'production') { | ||
| mapboxGeocodingUrl += '&permanent=true'; |
There was a problem hiding this comment.
We need to use this prop to be allowed to save locations locally.
There was a problem hiding this comment.
feel free to add this as a comment, it will be forgotten
There was a problem hiding this comment.
could also use URL instead of string concat for all the other params, much less error prone
| const response = await fetch(mapboxUrl); | ||
|
|
||
| if (!response.ok) { | ||
| return []; |
There was a problem hiding this comment.
Not sure if we wanna throw an error here or just return empty? Cause if the user starts typing again it will trigger the endpoint again, and then we might have an OK response.
| const response = await fetch(mapboxGeocodingUrl); | ||
|
|
||
| if (!response.ok) { | ||
| throw new Error('Mapbox API error'); |
There was a problem hiding this comment.
Not sure what type of error would be appropriate here?
There was a problem hiding this comment.
Error is fine, it will be 5xx, but maybe you want to add alerts if you think its necessary we know when it fails.
Also with 3party integrations we usually use Garmr for automatic retries, failover and so on so ideally you add that. Garmr will automatically notifiy on the channel.
There was a problem hiding this comment.
I thought this added alerts:
ctx.log.error(
{ error },
'Failed to fetch location autocomplete from Mapbox',
);
Is there something specific we need to do to hook it up to our slack channel?
There was a problem hiding this comment.
if you hook up garmr there are alerts for it automatically so you don't need to do anything
There was a problem hiding this comment.
as for log, it does not send all logs to slack, that would be so spammy 😆 you have to set manual alert for it, I can show you, but as said, garmr should be enough here without manual ctx.log.error call
| return await importEntity(con, params.entity); | ||
| } | ||
|
|
||
| await importEntity(con, 'DatasetLocation'); |
| externalLocationId: z.preprocess( | ||
| (val) => (val === '' ? null : val), | ||
| z.string().uuid().nullable().optional().default(null), | ||
| z.string().nullable().optional().default(null), |
There was a problem hiding this comment.
there is nullish which is shorthand for nullable and optional
| import type { DataSource } from 'typeorm/data-source'; | ||
| import { DatasetLocation } from './DatasetLocation'; | ||
|
|
||
| export interface MapboxContext { |
There was a problem hiding this comment.
let's move this to common or integrations, like we have for other 3party stuff, entity folder is plagued with dependency cycles so it would ideally be as clean as possible to avoid new cycles imports
| let mapboxGeocodingUrl = `${process.env.MAPBOX_GEOCODING_URL}?q=${encodeURIComponent(externalId)}&access_token=${process.env.MAPBOX_ACCESS_TOKEN}`; | ||
|
|
||
| if (process.env.NODE_ENV === 'production') { | ||
| mapboxGeocodingUrl += '&permanent=true'; |
There was a problem hiding this comment.
feel free to add this as a comment, it will be forgotten
| let mapboxGeocodingUrl = `${process.env.MAPBOX_GEOCODING_URL}?q=${encodeURIComponent(externalId)}&access_token=${process.env.MAPBOX_ACCESS_TOKEN}`; | ||
|
|
||
| if (process.env.NODE_ENV === 'production') { | ||
| mapboxGeocodingUrl += '&permanent=true'; |
There was a problem hiding this comment.
could also use URL instead of string concat for all the other params, much less error prone
| const response = await fetch(mapboxGeocodingUrl); | ||
|
|
||
| if (!response.ok) { | ||
| throw new Error('Mapbox API error'); |
There was a problem hiding this comment.
Error is fine, it will be 5xx, but maybe you want to add alerts if you think its necessary we know when it fails.
Also with 3party integrations we usually use Garmr for automatic retries, failover and so on so ideally you add that. Garmr will automatically notifiy on the channel.
| const readmeHtml = markdown.render(data.readme || ''); | ||
|
|
||
| try { | ||
| const formProps = excludeProperties(data, ['externalLocationId']); |
There was a problem hiding this comment.
We had discussion for excludeProperties multiple times before and yes, pro is you can just exclude only one field you need, but ideally I would rather specifically do delete data.externalLocationId here or remove it inside externalLocationId, I don't see the point of this helper personally
There was a problem hiding this comment.
Fair enough. Thought I'd use it since we already have it, but I can just delete the prop as well. I'm not very opinionated 😄
There was a problem hiding this comment.
its just bad in every way, performance wise as well, excludeProperties will iterate over all properties of an object to find one to delete, where delete will just do it 😆
The one in boot is also there for legacy reasons :hidethepain:
| }, | ||
| retryOpts: { | ||
| maxAttempts: 3, | ||
| backoff: 1000, |
There was a problem hiding this comment.
This will wait for 1000ms after each retry so if we hit rate limit and it keeps failing it will delay any request that calls this for 3+ seconds?
Just making sure its what you want?
After a lot of back and forth we decided that we are going to use Mapbox API instead of seeded data, due to the data we got being very low quality.
I removed the timezone and ranking for two reasons: