Skip to content

Implement code frequency graph #29191

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 21 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Extract duplicate code to seperate file
  • Loading branch information
sahinakkaya committed Feb 16, 2024
commit ccae9a998d91fb73b75fe2baf5bb85bc561919dd
19 changes: 3 additions & 16 deletions web_src/js/components/RepoCodeFrequency.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,12 @@ import {
firstStartDateAfterDate,
fillEmptyStartDaysWithZeroes,
} from '../utils/time.js';
import { colors } from '../utils/color.js'
import { sleep } from '../utils.js'
import 'chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm';

const {pageData} = window.config;

const colors = {
text: '--color-text',
border: '--color-secondary-alpha-60',
commits: '--color-primary-alpha-60',
additions: '--color-green',
deletions: '--color-red',
};

const styles = window.getComputedStyle(document.documentElement);
const getColor = (name) => styles.getPropertyValue(name).trim();

for (const [key, value] of Object.entries(colors)) {
colors[key] = getColor(value);
}

Chart.defaults.color = colors.text;
Chart.defaults.borderColor = colors.border;

Expand Down Expand Up @@ -82,7 +69,7 @@ export default {
do {
response = await GET(`${this.repoLink}/activity/code-frequency/data`);
if (response.status === 202) {
await new Promise((resolve) => setTimeout(resolve, 1000)); // wait for 1 second before retrying
await sleep(1000); // wait for 1 second before retrying
}
} while (response.status === 202);
if (response.ok) {
Expand Down
20 changes: 3 additions & 17 deletions web_src/js/components/RepoContributors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,13 @@ import {
firstStartDateAfterDate,
fillEmptyStartDaysWithZeroes,
} from '../utils/time.js';
import { colors } from '../utils/color.js'
import { sleep } from '../utils.js'
import 'chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm';
import $ from 'jquery';

const {pageData} = window.config;

const colors = {
text: '--color-text',
border: '--color-secondary-alpha-60',
commits: '--color-primary-alpha-60',
additions: '--color-green',
deletions: '--color-red',
title: '--color-secondary-dark-4',
};

const styles = window.getComputedStyle(document.documentElement);
const getColor = (name) => styles.getPropertyValue(name).trim();

for (const [key, value] of Object.entries(colors)) {
colors[key] = getColor(value);
}

const customEventListener = {
id: 'customEventListener',
afterEvent: (chart, args, opts) => {
Expand Down Expand Up @@ -122,7 +108,7 @@ export default {
do {
response = await GET(`${this.repoLink}/activity/contributors/data`);
if (response.status === 202) {
await new Promise((resolve) => setTimeout(resolve, 1000)); // wait for 1 second before retrying
await sleep(1000); // wait for 1 second before retrying
}
} while (response.status === 202);
if (response.ok) {
Expand Down
2 changes: 2 additions & 0 deletions web_src/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,5 @@ export function parseDom(text, contentType) {
export function serializeXml(node) {
return xmlSerializer.serializeToString(node);
}

export const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
16 changes: 16 additions & 0 deletions web_src/js/utils/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,19 @@ function getLuminance(r, g, b) {
export function useLightTextOnBackground(r, g, b) {
return getLuminance(r, g, b) < 0.453;
}


export const colors = {
text: '--color-text',
border: '--color-secondary-alpha-60',
commits: '--color-primary-alpha-60',
additions: '--color-green',
deletions: '--color-red',
};

const styles = window.getComputedStyle(document.documentElement);
const getColor = (name) => styles.getPropertyValue(name).trim();

for (const [key, value] of Object.entries(colors)) {
colors[key] = getColor(value);
}