Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtual branch #320

Merged
merged 3 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"allow": ["@windy"],
"depConstraints": [
{
"sourceTag": "*",
Expand Down
18 changes: 15 additions & 3 deletions apps/fetcher/src/app/misc/buy-coffee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import { fetchResponse } from '@flyxc/common';
import { Secrets } from '@flyxc/secrets';
import { format, subMonths } from 'date-fns';

export type Supporters = {
// visible supporters
Expand All @@ -12,14 +13,21 @@ export type Supporters = {
numSupporters: number;
// total amount
totalAmount: number;
// last3MonthsAmount
last3MonthsAmount: number;
};

export async function fetchSupporters(): Promise<Supporters> {
const supporters: Supporters = {
names: new Set<string>(),
numSupporters: 0,
totalAmount: 0,
last3MonthsAmount: 0,
};

const cutoffDate = subMonths(new Date(), 3);
const cutoffDateString = format(cutoffDate, 'yyyy-MM-dd');

let url = `https://developers.buymeacoffee.com/api/v1/supporters`;
try {
while (url) {
Expand All @@ -32,14 +40,18 @@ export async function fetchSupporters(): Promise<Supporters> {
const data = await response.json();
const users = data.data;
for (const user of users) {
if (user.amount <= 0 || user.is_refunded) {
if (user.is_refunded) {
continue;
}
if (user.support_visibility === 1 && user.payer_name) {
if (user.support_visibility === 1 && user.payer_name.length > 3 && user.payer_name !== 'Someone') {
supporters.names.add(user.payer_name);
}
supporters.numSupporters++;
supporters.totalAmount += user.support_coffees * user.support_coffee_price;
const amount = user.support_coffees * user.support_coffee_price;
supporters.totalAmount += amount;
if (user.support_created_on >= cutoffDateString) {
supporters.last3MonthsAmount += amount;
}
}
url = data.next_page_url;
} else {
Expand Down
9 changes: 5 additions & 4 deletions apps/fetcher/src/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
removeBeforeFromLiveTrack,
removeDeviceFromLiveTrack,
} from '@flyxc/common';
import { getDatastore, getRedisClient, pushListCap } from '@flyxc/common-node';
import { getDatastore, getRedisClient } from '@flyxc/common-node';
import { Secrets } from '@flyxc/secrets';
import type { Datastore } from '@google-cloud/datastore';
import { program } from 'commander';
Expand Down Expand Up @@ -134,9 +134,10 @@ async function tick(state: protos.FetcherState, datastore: Datastore) {
pipeline
.del(Keys.supporterNames)
.set(Keys.supporterNum, supporters.numSupporters)
.set(Keys.supporterAmount, supporters.totalAmount);
pushListCap(pipeline, Keys.supporterNames, Array.from(supporters.names), 50, 50);

.set(Keys.supporterAmount, supporters.totalAmount)
.set(Keys.supporterLast3MonthsAmount, supporters.last3MonthsAmount)
.del(Keys.supporterNames)
.rpush(Keys.supporterNames, ...Array.from(supporters.names).slice(0, 50));
state.nextSupporterSyncSec = state.lastTickSec + SUPPORTER_SYNC_SEC;
}

Expand Down
10 changes: 6 additions & 4 deletions apps/fxc-front/src/app/components/ui/supporter-modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { modalController } from '@ionic/core/components';
import type { TemplateResult } from 'lit';
import { html, LitElement } from 'lit';
import { customElement } from 'lit/decorators.js';
import { when } from 'lit/directives/when.js';

@customElement('supporter-modal')
export class SupporterModal extends LitElement {
private supporters = { names: [], amount: 0, number: 0 };
private supporters = { names: [], amount: 0, number: 0, amountLast3Months: 0 };

async connectedCallback(): Promise<void> {
super.connectedCallback();
Expand Down Expand Up @@ -38,7 +39,7 @@ export class SupporterModal extends LitElement {
</p>
<p>
If you can afford it, please consider supporting flyXC with a small donation by clicking the button below.
It will help keep me motivated to maintain and improve it.
It will help keep the contributors motivated to maintain and improve it.
</p>
</ion-text>

Expand All @@ -52,10 +53,11 @@ export class SupporterModal extends LitElement {

<p>
<ion-text color="dark"
>Thanks to the ${this.supporters.number} supporters who have contributed a total of
$${this.supporters.amount}:
>Thanks to the ${this.supporters.number} supporters who have contributed
$${this.supporters.amountLast3Months} over the last 3 months and a total of $${this.supporters.amount}:
<ul>
${this.supporters.names.map((n) => html`<li>${n}</li>`)}
${when(this.supporters.names.length > 30, () => html`<li>...</li>`)}
</ul>
</ion-text>
</p>
Expand Down
8 changes: 4 additions & 4 deletions apps/fxc-server/src/app/routes/supporters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ import type { Redis } from 'ioredis';
export function getSupportersRouter(redis: Redis): Router {
const router = Router();

// Returns the airspaces info for the first track in the group as JSON.
// Returns 404 if the info are not available (/not ready yet).
// Returns the supporter info
// eslint-disable-next-line @typescript-eslint/no-unused-vars
router.get('/supporters.json', async (req: Request, res: Response) => {
try {
const [names, number, amount] = (
const [names, number, amount, amountLast3Months] = (
await redis
.pipeline()
.lrange(Keys.supporterNames, 0, 100)
.get(Keys.supporterNum)
.get(Keys.supporterAmount)
.get(Keys.supporterLast3MonthsAmount)
.exec()
).map(([_, v]) => v);
return res.json({ names, number, amount });
return res.json({ names, number, amount, amountLast3Months });
} catch (error) {
return res.sendStatus(500);
}
Expand Down
1 change: 1 addition & 0 deletions libs/common/src/lib/redis-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export enum Keys {
supporterNames = 'f:supporters',
supporterNum = 'f:supporters:num',
supporterAmount = 'f:supporters:amount',
supporterLast3MonthsAmount = 'f:supporters:amount3m',

// [List]
proxyInreach = 'p:inreach:logs',
Expand Down
9 changes: 5 additions & 4 deletions libs/optimizer/src/lib/optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,15 @@ function toUnoptimizedSolution(track: ScoringTrack): Solution {
score: distance,
},
opt: {
launch: 0,
landing: track.points.length - 1,
scoring: {
name: '',
code: 'od',
multiplier: 1,
},
flight: undefined as any,
config: {},
},
optimal: true,
id: 0,
Expand Down Expand Up @@ -256,15 +259,13 @@ function getClosingRadiusKm(solution: Solution): number | undefined {
return undefined;
}

// TODO: remove cast when https://github.com/mmomtchev/igc-xc-score/pull/233 is merged
const closingDistanceFixed = (solution.opt.scoring as any)?.closingDistanceFixed;
const closingDistanceFixed = solution.opt.scoring.closingDistanceFixed;
vicb marked this conversation as resolved.
Show resolved Hide resolved

if (closingDistanceFixed != null && closingDistance < closingDistanceFixed) {
return closingDistanceFixed;
}

// TODO: remove cast when https://github.com/mmomtchev/igc-xc-score/pull/233 is merged
const closingDistanceRelativeRatio = (solution.opt.scoring as any)?.closingDistanceRelative;
const closingDistanceRelativeRatio = solution.opt.scoring.closingDistanceRelative;
const closingDistanceRelative =
solution.scoreInfo?.distance != null && closingDistanceRelativeRatio != null
? closingDistanceRelativeRatio * solution.scoreInfo.distance
Expand Down
2 changes: 1 addition & 1 deletion libs/secrets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"private": true,
"dependencies": {
"dotenv-webpack": "^8.1.0",
"@nx/webpack": "19.8.0"
"@nx/webpack": "19.8.2"
}
}
1 change: 0 additions & 1 deletion libs/windy-sounding/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/.env.local
/types
4 changes: 4 additions & 0 deletions libs/windy-sounding/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release history

## 4.1.8

- Drop `@windy.com/devtools`
vicb marked this conversation as resolved.
Show resolved Hide resolved

## 4.1.7 - Sep 14, 2024

- Update the list of supported models to exclude AROME-HD
Expand Down
55 changes: 55 additions & 0 deletions libs/windy-sounding/https.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Extracted from @windycom/plugin-devtools

export const certificatePEM = `
vicb marked this conversation as resolved.
Show resolved Hide resolved
-----BEGIN CERTI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mjpVnt86px7NXMsdBOLHJyJMAB2iLgR7gy/StV1zxSX
l48WMLKAXRnbcrsrAUXgfkJbaviTyvCgwFmx99yc4oP9onbEbNQJdp4gTrat
-----END CERTIFICATE-----
`;

export const keyPEM = `
vicb marked this conversation as resolved.
Show resolved Hide resolved
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDKLfu9uX9A97rU
E0kTGa7COeShMz4SJVQI+2Z7dV+6MC42rNpvbPjyWMKMjMTip6ARYrDtG6ARNETV
+RIYBOIAEU5InKGJNdpOSlTxFq87XDTwdYtG9XLYhQZTOFSkDjgwZkFfcXDbnhwz
yu2tF+nPP1kt7k0qt0AwNn/QI3RvRlWC9gpX644xHyJPp6H76M4gxYvNw9Eh+Urb
Abp27+tnQEd+qQi9adK3qi2C0GL787HEhIA18A4EJY7PIrINNjD4r9IiFF78pZFX
EUszE2aE4GVe8v12VmhRPntPUgKLskFZAuAnKOxan8zar7b5bIDq9M0l/+JqN7x+
nB9Cx9kLAgMBAAECggEBAKIE/ZNJ3t+KZs7i8ZF76F8/k6dW8CwMe+6CwNq48dC8
IZyxIo9erZVQaf/GI1VbbVvhUdWBaOHAmFU8tzJGX3IcbDamRpE1dc99o9pcCmsw
dkAogkeIFNPMrofsQXAC8SZgG41H1GA6sXET8yneWwE5S9cR/Ab6OVcppX1/nCQ6
tSLCTi5Uxqq1T2qdVPwGsm0GtE3XvLkfhoQBjt46T+pOVECshkFIIcpRdLaK/Q7+
PUfQDEgmsqV1qViLMm01nFJTHlZvL3rVS64HojPXXB6gtuCAN7K9RKWUlwhlklPb
M+ydISklWwbvLbIqALKsGqeLk7tf9FHd7WFJHUnTkkkCgYEA6wnYfTAGuAoAHMoa
7mVrSqxytlKcudnkr0LaTvBQ0o0IRLPi21kZIZzjT6jt5SSZmwZzvwr0TFCCuvHW
wfJnSdYCy/oB/g4D2oViGKus4sbzlS1MOvPNzlUzyp1h2ugdgBlyCzopn9MgZQVg
uOyzY34ChIdhyDE8yWmOI9cQSqUCgYEA3DXwViUToYuvgjq3+UfZDFMjSYJd3LOO
NjzhRxNxWZJxEXbO799m/zDSmWUJU/wPTJcIyM9eYcRxCoj2JyyLy0dGmq/2n8Nv
hQj0NpeEdpm6dn0kJMnNgSeqrjbMIlkgYkafp+24lbUnyiJV8akV/twYylBOfCuQ
jKKov0pGNe8CgYEA47RSLFZO7BWkLkAO/076NwoCyGgYtmVGjBT0cu2XH6TKkeTE
r0UOd+YKwq4ia5Cdz/bcRAVU0GpffMW3DYbOUlYnt32qWHszeI0okEYh5EJi0e9k
nuh8Rp1845q9ptqhWe1M81uR3+kmxTgEkKOg147I2aRfMxegkHDW6Bn/CpECgYB2
3C5jcRPNiIYtNuCCjwNaoa1USie7rrc+E1JNePMfs+mP0Z8U3nLLn2CtJ1oHmO/x
GTzGlxeMkemqFA85SdQS3t//MqddyLFzD0gyB0qacZOxzQ4rRTnFUtHPwwggKhdO
tGwMykVtmSBm/G2DSQ70R3yiBwK2BxW4szt+NOr8xQKBgFZKzJJJCI7tIx4Q4W6u
eXBYiWI6UlNpl7NRaaomk1rfIF6mZwN4jdNMSCaYxMRS6AeMBLF7a3t1SaZ+rOAM
h3aspktieVxk6EW6XE5niS8FphEdWc2ttqPYTEH/xlnyk5huBtgUbIWfjdK2sPcy
5MnCHcPPkW3bLxyZSC9y84aP
-----END PRIVATE KEY-----
`;
2 changes: 1 addition & 1 deletion libs/windy-sounding/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"jsxFragmentFactory": "Fragment"
},
"files": [],
"include": ["src"],
"include": ["src", "https.ts", "types"],
"references": [
{
"path": "./tsconfig.lib.json"
Expand Down
2 changes: 1 addition & 1 deletion libs/windy-sounding/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"declaration": true,
"types": ["node", "vite/client", "svelte"]
},
"include": ["src/**/*.ts", "src/**/*.svelte"],
"include": ["src/**/*.ts", "src/**/*.svelte", "https.ts"],
"exclude": ["vite.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
}
1 change: 1 addition & 0 deletions libs/windy-sounding/types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Extracted from @windycom/plugin-devtools
5 changes: 5 additions & 0 deletions libs/windy-sounding/types/client/AromeProduct.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Product } from '@windy/Product';
import type { ProductInitParams } from '@windy/Product';
export declare class AromeProduct extends Product {
constructor(params: Partial<ProductInitParams>);
}
Loading
Loading