Skip to content

Commit

Permalink
🔥hot fix/prod h2h issues (#982)
Browse files Browse the repository at this point in the history
* `update` README.md

* `issue` #972 #976

* `issue` #972

* `deepsource` JS-0357

* `deepsource` JS-0128

* `deepsource` JS-0051

* `deepsource` JS-0116

* `deepsource` JS-0246

* `deepsource` JS-0241

* `deepsource` JS-0241

* `deepsource` JS-0123

* `deepsource` JS-0356
  • Loading branch information
migbash authored Jan 13, 2023
1 parent 7d4c8e6 commit 0aff484
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 58 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ npm run dev
npm run dev -- --open
```

### Dev Environment [Codespaces]

If you're using `codespaces` enabled for the `scores-platform` development - simply launch the
`dev` branch and once the `codespace` has successfully loaded run the following commands:

```
npm install -g [email protected]
npm install
```

### Production Environment

Before creating a production version of your app, install an [adapter](https://kit.svelte.dev/docs#adapters) for your target environment. Then:
Expand Down
2 changes: 1 addition & 1 deletion my-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const app = express();
* [ℹ] separate from SvelteKit endpoint in attempts to
* [ℹ] identify clients (IP - address)
*/
app.get('/getClientIP', (req, res, next) => {
app.get('/getClientIP', (req, res) => {

const ip = req.headers['x-forwarded-for'] ||
req.socket.remoteAddress ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,15 @@
FIXTURE_PROB_DATA.time = HIST_FIXTURE_DATA?.time
// [ℹ] calcuate (%) of 5 matches
if (FIXTURE_INFO?.data?.home_team_name == FIXTURE_H2H?.teams_data[0].team_name) {
team1Percent = ((FIXTURE_H2H?.data?.wins_draws?.team_1 / 5) * 100)
team2Percent = ((FIXTURE_H2H?.data?.wins_draws?.team_2 / 5) * 100)
}
else {
if ((FIXTURE_H2H?.teams_data.find( ({ team_name }) => team_name == FIXTURE_INFO?.data?.home_team_name).team_id
> FIXTURE_H2H?.teams_data.find( ({ team_name }) => team_name == FIXTURE_INFO?.data?.away_team_name).team_id)) {
team1Percent = ((FIXTURE_H2H?.data?.wins_draws?.team_2 / 5) * 100)
team2Percent = ((FIXTURE_H2H?.data?.wins_draws?.team_1 / 5) * 100)
}
else {
team1Percent = ((FIXTURE_H2H?.data?.wins_draws?.team_1 / 5) * 100)
team2Percent = ((FIXTURE_H2H?.data?.wins_draws?.team_2 / 5) * 100)
}
// [ℹ] regardless of STATUS,
// [ℹ] VOTE_DATA is shown until it is erased from "/odds"
Expand Down Expand Up @@ -665,10 +666,11 @@
color-black-2
main-txt
">
{#if FIXTURE_INFO?.data?.home_team_name == FIXTURE_H2H?.teams_data[0].team_name}
{FIXTURE_H2H?.data?.wins_draws?.team_1}
{:else}
{#if (FIXTURE_H2H?.teams_data.find( ({ team_name }) => team_name == FIXTURE_INFO?.data?.home_team_name).team_id
> FIXTURE_H2H?.teams_data.find( ({ team_name }) => team_name == FIXTURE_INFO?.data?.away_team_name).team_id)}
{FIXTURE_H2H?.data?.wins_draws?.team_2}
{:else}
{FIXTURE_H2H?.data?.wins_draws?.team_1}
{/if}
</p>
<p
Expand Down Expand Up @@ -705,10 +707,11 @@
color-black-2
main-txt
">
{#if FIXTURE_INFO?.data?.away_team_name == FIXTURE_H2H?.teams_data[0].team_name}
{FIXTURE_H2H?.data?.wins_draws?.team_1}
{:else}
{#if (FIXTURE_H2H?.teams_data.find( ({ team_name }) => team_name == FIXTURE_INFO?.data?.away_team_name).team_id
> FIXTURE_H2H?.teams_data.find( ({ team_name }) => team_name == FIXTURE_INFO?.data?.home_team_name).team_id)}
{FIXTURE_H2H?.data?.wins_draws?.team_2}
{:else}
{FIXTURE_H2H?.data?.wins_draws?.team_1}
{/if}
</p>
<p
Expand Down Expand Up @@ -765,7 +768,7 @@
w-500
color-black-2
">
{FIXTURE_H2H?.teams_data[0].team_name}
{FIXTURE_H2H?.teams_data.find( ({ team_name }) => team_name == FIXTURE_INFO?.data?.home_team_name).team_name}
</p>
{/if}
<div
Expand All @@ -790,7 +793,7 @@
w-500
color-black-2
">
{FIXTURE_H2H?.teams_data[1].team_name}
{FIXTURE_H2H?.teams_data.find( ({ team_name }) => team_name == FIXTURE_INFO?.data?.away_team_name).team_name}
</p>
{/if}
<div
Expand Down Expand Up @@ -1226,7 +1229,7 @@
}
}
@media only screen and (max-width: 865px) {
@media only screen and (min-width: 726px) and (max-width: 865px) {
/* past-fixture-data */
div#list-past-fixtures-box div.past-fixture-row {
Expand Down
11 changes: 1 addition & 10 deletions src/lib/firebase/featured_betting_sites/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,11 @@ import { child, get, ref } from 'firebase/database';
* ... @param userGeoLocation
*/
export async function getAllSportbookDetails(): Promise<unknown> {

// ... get all the `sportbook_details` data from `Firebase DB`;
return get(child(ref(db_real), `sportsbook_details`)).then((snapshot) => {

// ... existance verifying;
return await get(child(ref(db_real), `sportsbook_details`)).then((snapshot) => {
if (snapshot.exists()) {

// ... return RAW DATA;
return snapshot.val()

// ... else, return `empty`;
} else {

// ... return null;
return;
}
})
Expand Down
8 changes: 4 additions & 4 deletions src/lib/firebase/fixtures_odds/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { child, get, ref } from 'firebase/database'

export async function getLivescoresNow(): Promise < unknown > {

return get(child(ref(db_real), `livescores_now`))
return await get(child(ref(db_real), `livescores_now`))
.then((snapshot) => {
if (snapshot.exists()) {
return snapshot.val()
Expand All @@ -26,7 +26,7 @@ export async function getOdds (

// [ℹ] iterate over ALL fixtures
// [ℹ] of SELECTED season
for (const season_fixture_date_group of fixtures_arr_filter) {
for await (const season_fixture_date_group of fixtures_arr_filter) {

// [ℹ] convert the datetime to the correct variables to search for the fixture;
const year_: string = new Date(season_fixture_date_group.date).getFullYear().toString();
Expand All @@ -39,15 +39,15 @@ export async function getOdds (
// [ℹ] iterater over fixtures
// [ℹ] [BY DATE GROUP]
// [ℹ] assign "onValue" event-listeners
for (const season_fixture of season_fixture_date_group.fixtures) {
for await (const season_fixture of season_fixture_date_group.fixtures) {

if (season_fixture.status == "FT") {
continue
}

const fixture_id = season_fixture.id;

get(child(ref(db_real), 'odds/' + year_ + '/' + new_month_ + '/' + day_ + '/' + fixture_id))
get(child(ref(db_real), `odds/${year_}/${new_month_}/${day_}/${fixture_id}`))
.then((snapshot) => {
if (snapshot.exists()) {
const sportbook_array: FIREBASE_odds[] = []
Expand Down
4 changes: 2 additions & 2 deletions src/lib/firebase/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ export async function getTargetFixtureOdds (
const map = new Map();
let count = 0;
// ... iterate over the data of the `lang` in sportbook details;
for (const rankedOdd in sportbook_details) {
for (const rankedOdd of Object.keys(sportbook_details)) {
// ... iterate over the data of the fixture avaiable ODDS;
for (const avaiableOdd in fixture_odds_keys) {
for (const avaiableOdd of Object.keys(fixture_odds_keys)) {
// ...
const targetFixture = fixture_odds_keys[avaiableOdd];
const fixtureOdd = fixture_odds[targetFixture];
Expand Down
40 changes: 20 additions & 20 deletions src/lib/utils/color_thief.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@ import ColorThief from 'colorthief/dist/color-thief.mjs';
// [ℹ] declaring a new instance of `ColorThief`;
const colorThief = new ColorThief();

/**
* Description:
* ~~~~~~~~~~~~~~~~~~~~
* A function-method to convert the
* [x,a,c] of RBG values to `#HEX` values
* @param r
* @param g
* @param b
* @returns (# a singel #HEX-Color Value)
*/
export const rgbToHex = (r, g, b) =>
'#' + [r, g, b]
.map((x) => {
const hex = x.toString(16);
return hex.length === 1 ? `0${hex}` : hex;
})
.join('');

/**
* Description:
* ~~~~~~~~~~~~~~~~~~~~
Expand All @@ -23,7 +41,7 @@ export function getImageBgColor(imgURL: string, imageVar: string) {
// instantiate the image Type;
const img = new Image();
// listen, event to wait for the image to load
img.addEventListener('load', function () {
img.addEventListener('load', () => {
// get the array of RGB values,
const colorValues = colorThief.getColor(img);
// convert the RGB values to HEX value,
Expand All @@ -42,22 +60,4 @@ export function getImageBgColor(imgURL: string, imageVar: string) {
catch (e) {
if (dev) console.error('-- getImageBgColor() ERR --', e);
}
}

/**
* Description:
* ~~~~~~~~~~~~~~~~~~~~
* A function-method to convert the
* [x,a,c] of RBG values to `#HEX` values
* @param r
* @param g
* @param b
* @returns (# a singel #HEX-Color Value)
*/
export const rgbToHex = (r, g, b) =>
'#' + [r, g, b]
.map((x) => {
const hex = x.toString(16);
return hex.length === 1 ? '0' + hex : hex;
})
.join('');
}
4 changes: 2 additions & 2 deletions src/routes/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ export async function load ({
// '/api/cache/leagues_table?geoPos='+'en',
];

const promises = urls.map((url) =>
fetch(url)
const promises = urls.map((_url) =>
fetch(_url)
.then((response) => response.json())
);

Expand Down
4 changes: 2 additions & 2 deletions src/routes/[lang=lang]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ export async function load ({
// '/api/cache/leagues_table?geoPos='+'en',
];

const promises = urls.map((url) =>
fetch(url)
const promises = urls.map((_url) =>
fetch(_url)
.then((response) => response.json())
);

Expand Down
4 changes: 2 additions & 2 deletions src/routes/api/hasura/fixtures/head-2-head/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ async function main (
{
team_logo: team_1_data?.data?.logo_path,
team_name: team_1_data?.data?.name,
team_short: team_1_data?.data?.short_code,
team_short: team_1_data?.data?.short_code || team_1_data?.data?.name.slice(0, 3).toUpperCase() || null,
team_id: team_ids_arr[0],
},
{
team_logo: team_2_data?.data?.logo_path,
team_name: team_2_data?.data?.name,
team_short: team_2_data?.data?.short_code,
team_short: team_2_data?.data?.short_code || team_2_data?.data?.name.slice(0, 3).toUpperCase() || null,
team_id: team_ids_arr[1],
}
],
Expand Down
2 changes: 1 addition & 1 deletion src/routes/api/hasura/fixtures/lineups/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ async function get_target_player_data (
playerIdsArr: number[]
): Promise < BETARENA_HASURA_SURGICAL_JSONB_scores_football_players[] > {

playerIdsArr = playerIdsArr.filter(function (el) {
playerIdsArr = playerIdsArr.filter((el) => {
return el != undefined;
});

Expand Down

0 comments on commit 0aff484

Please sign in to comment.