-
Notifications
You must be signed in to change notification settings - Fork 0
Migrate GoodAction Hub to standalone data repository API #4
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
682e22c
Initial plan
Copilot 5f7dac8
feat: migrate data loading to GoodAction-data external API
Copilot 6ec1760
feat: migrate data loading to GoodAction-data external API
Copilot 1df067c
style: add .prettierrc (semi:false, singleQuote:true) and reformat al…
Copilot fb08f7d
style: move prettier config into package.json, remove .prettierrc
Copilot 5dbf22c
feat: rewrite migration from scratch, restore all non-migration files…
Copilot 4798e65
chore: restore all non-migration files to main branch state via .pret…
Copilot cb216df
feat: API-driven Barrier-Free-Bites page, shared SafeTranslation, Goo…
Copilot 93fe40b
refactor: extract SVG icons to components/icons, move CSS to page.mod…
Copilot 89cfc42
fix: use :global(:root) in CSS module for explicit global scope
Copilot b120b6a
refactor: delete data YAMLs, remove icon wrappers, replace all inline…
Copilot ae634a5
refactor: convert icon components to named FC arrow function exports
Copilot 0c192e8
[remove] outdated Static Data & Document
TechQuery File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,57 +1,60 @@ | ||
| import { $, YAML } from "npm:zx"; | ||
| import { $, YAML } from 'npm:zx' | ||
|
|
||
| import { Reward } from "./type.ts"; | ||
| import { Reward } from './type.ts' | ||
|
|
||
| $.verbose = true; | ||
| $.verbose = true | ||
|
|
||
| const rawTags = | ||
| await $`git tag --list "reward-*" --format="%(refname:short) %(creatordate:short)"`; | ||
| await $`git tag --list "reward-*" --format="%(refname:short) %(creatordate:short)"` | ||
|
|
||
| const lastMonth = new Date(); | ||
| lastMonth.setMonth(lastMonth.getMonth() - 1); | ||
| const lastMonthStr = lastMonth.toJSON().slice(0, 7); | ||
| const lastMonth = new Date() | ||
| lastMonth.setMonth(lastMonth.getMonth() - 1) | ||
| const lastMonthStr = lastMonth.toJSON().slice(0, 7) | ||
|
|
||
| const rewardTags = rawTags.stdout | ||
| .split("\n") | ||
| .split('\n') | ||
| .filter((line) => line.split(/\s+/)[1] >= lastMonthStr) | ||
| .map((line) => line.split(/\s+/)[0]); | ||
| .map((line) => line.split(/\s+/)[0]) | ||
|
|
||
| let rawYAML = ""; | ||
| let rawYAML = '' | ||
|
|
||
| for (const tag of rewardTags) | ||
| rawYAML += (await $`git tag -l --format="%(contents)" ${tag}`) + "\n"; | ||
| rawYAML += (await $`git tag -l --format="%(contents)" ${tag}`) + '\n' | ||
|
|
||
| if (!rawYAML.trim()) | ||
| throw new ReferenceError("No reward data is found for the last month."); | ||
| throw new ReferenceError('No reward data is found for the last month.') | ||
|
|
||
| const rewards = YAML.parse(rawYAML) as Reward[]; | ||
| const rewards = YAML.parse(rawYAML) as Reward[] | ||
|
|
||
| const groupedRewards = Object.groupBy(rewards, ({ payee }) => payee); | ||
| const groupedRewards = Object.groupBy(rewards, ({ payee }) => payee) | ||
|
|
||
| const summaryList = Object.entries(groupedRewards).map(([payee, rewards]) => { | ||
| const reward = rewards!.reduce((acc, { currency, reward }) => { | ||
| acc[currency] ??= 0; | ||
| acc[currency] += reward; | ||
| return acc; | ||
| }, {} as Record<string, number>); | ||
| const reward = rewards!.reduce( | ||
| (acc, { currency, reward }) => { | ||
| acc[currency] ??= 0 | ||
| acc[currency] += reward | ||
| return acc | ||
| }, | ||
| {} as Record<string, number>, | ||
| ) | ||
|
|
||
| return { | ||
| payee, | ||
| reward, | ||
| accounts: rewards!.map(({ payee: _, ...account }) => account), | ||
| }; | ||
| }); | ||
| accounts: rewards!.map(({ payee: _payee, ...account }) => account), | ||
| } | ||
| }) | ||
|
|
||
| const summaryText = YAML.stringify(summaryList); | ||
| const summaryText = YAML.stringify(summaryList) | ||
|
|
||
| console.log(summaryText); | ||
| console.log(summaryText) | ||
|
|
||
| const tagName = `statistic-${new Date().toJSON().slice(0, 7)}`; | ||
| const tagName = `statistic-${new Date().toJSON().slice(0, 7)}` | ||
|
|
||
| await $`git config user.name "github-actions[bot]"`; | ||
| await $`git config user.email "github-actions[bot]@users.noreply.github.com"`; | ||
| await $`git config user.name "github-actions[bot]"` | ||
| await $`git config user.email "github-actions[bot]@users.noreply.github.com"` | ||
|
|
||
| await $`git tag -a ${tagName} $(git rev-parse HEAD) -m ${summaryText}`; | ||
| await $`git push origin --tags --no-verify`; | ||
| await $`git tag -a ${tagName} $(git rev-parse HEAD) -m ${summaryText}` | ||
| await $`git push origin --tags --no-verify` | ||
|
|
||
| await $`gh release create ${tagName} --notes ${summaryText}`; | ||
| await $`gh release create ${tagName} --notes ${summaryText}` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| export interface Reward { | ||
| issue: string; | ||
| payer: string; | ||
| payee: string; | ||
| currency: string; | ||
| reward: number; | ||
| issue: string | ||
| payer: string | ||
| payee: string | ||
| currency: string | ||
| reward: number | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "semi": false, | ||
| "singleQuote": true | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| import type { Metadata } from "next"; | ||
| import React from "react"; | ||
| import type { Metadata } from 'next' | ||
| import React from 'react' | ||
|
|
||
| export const metadata: Metadata = { | ||
| title: "无障碍友好美食指南", | ||
| }; | ||
| title: '无障碍友好美食指南', | ||
| } | ||
|
|
||
| export default function Layout({ children }: { children: React.ReactNode }) { | ||
| return children; | ||
| } | ||
| return children | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.