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

🔥hot-fix to PROD #983

Merged
merged 2 commits into from
Jan 13, 2023
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
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 @@ -110,7 +110,8 @@
loaded = true;

const responses_invalid =
response == undefined
FIXTURE_H2H == undefined
|| response == undefined
|| response.historic_fixtures[0] == undefined
|| response.historic_fixtures[0]?.probabilities == undefined
|| response_main_sportbook == undefined
Expand Down Expand Up @@ -146,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 @@ -474,20 +476,23 @@
<div
id="seo-widget-box">
<!--
[ℹ] widget-title -->
<!-- <h2>{FIXTURE_VOTES_TRANSLATION?.widget_title}</h2> -->
<!--
[ℹ] team-names
[ℹ] widget-title
-->
{#each FIXTURE_H2H?.teams_data as item}
<p>{item?.team_name}</p>
{/each}
<!--
[ℹ] league-names [from-fixtures]
-->
{#each FIXTURE_H2H?.data?.last_5_data as item}
<p>{item?.league?.data?.name}</p>
{/each}
<!-- <h2>{FIXTURE_VOTES_TRANSLATION?.widget_title}</h2> -->
{#if FIXTURE_H2H != undefined}
<!--
[ℹ] team-names
-->
{#each FIXTURE_H2H?.teams_data as item}
<p>{item?.team_name}</p>
{/each}
<!--
[ℹ] league-names [from-fixtures]
-->
{#each FIXTURE_H2H?.data?.last_5_data as item}
<p>{item?.league?.data?.name}</p>
{/each}
{/if}
</div>
<!-- {/if} -->

Expand Down Expand Up @@ -661,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 @@ -701,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 @@ -761,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 @@ -786,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 @@ -1222,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
25 changes: 24 additions & 1 deletion src/routes/[lang=lang]/[sport]/[fixture=fixture]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,29 @@ export async function load({
* ==========
*/

// [🐞]
if (dev) {
console.log('fixture_id: ', fixture_id)
if (response_fixtures_seo == undefined) console.log("response_fixtures_seo is undefined")
if (response_fixtures_page_info == undefined) console.log("response_fixtures_page_info is undefined")
if (response_scoreboard == undefined) console.log("response_scoreboard is undefined")
if (response_scoreboard_translation == undefined) console.log("response_scoreboard_translation is undefined")
if (response_lineups == undefined) console.log("response_lineups is undefined")
if (response_lineups_translation == undefined) console.log("response_lineups_translation is undefined")
if (response_incidents == undefined) console.log("response_incidents is undefined")
if (response_incidents_translation == undefined) console.log("response_incidents_translation is undefined")
if (response_featured_betting_sites_translation == undefined) console.log("response_featured_betting_sites_translation is undefined")
if (response_statistics == undefined) console.log("response_statistics is undefined")
if (response_statistics_translation == undefined) console.log("response_statistics_translation is undefined")
if (response_content == undefined) console.log("response_content is undefined")
if (response_content_translation == undefined) console.log("response_content_translation is undefined")
if (response_about_translation == undefined) console.log("response_about_translation is undefined")
if (response_votes_translation == undefined) console.log("response_votes_translation is undefined")
if (response_h2h == undefined) console.log("response_h2h is undefined")
if (response_h2h_translation == undefined) console.log("response_h2h_translation is undefined")
if (response_fixtures_odds_translations == undefined) console.log("response_fixtures_odds_translations is undefined")
}

if (
response_fixtures_seo
&& response_fixtures_page_info
Expand All @@ -392,7 +415,7 @@ export async function load({
&& response_about_translation
&& response_votes_translation
&& response_probability_translation
&& response_h2h
// && response_h2h // IMPORTANT can be "NULL"
&& response_h2h_translation
// extra
&& response_fixtures_odds_translations
Expand Down
25 changes: 24 additions & 1 deletion src/routes/[sport]/[fixture=fixture]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,29 @@ export async function load({
* ==========
*/

// [🐞]
if (dev) {
console.log('fixture_id: ', fixture_id)
if (response_fixtures_seo == undefined) console.log("response_fixtures_seo is undefined")
if (response_fixtures_page_info == undefined) console.log("response_fixtures_page_info is undefined")
if (response_scoreboard == undefined) console.log("response_scoreboard is undefined")
if (response_scoreboard_translation == undefined) console.log("response_scoreboard_translation is undefined")
if (response_lineups == undefined) console.log("response_lineups is undefined")
if (response_lineups_translation == undefined) console.log("response_lineups_translation is undefined")
if (response_incidents == undefined) console.log("response_incidents is undefined")
if (response_incidents_translation == undefined) console.log("response_incidents_translation is undefined")
if (response_featured_betting_sites_translation == undefined) console.log("response_featured_betting_sites_translation is undefined")
if (response_statistics == undefined) console.log("response_statistics is undefined")
if (response_statistics_translation == undefined) console.log("response_statistics_translation is undefined")
if (response_content == undefined) console.log("response_content is undefined")
if (response_content_translation == undefined) console.log("response_content_translation is undefined")
if (response_about_translation == undefined) console.log("response_about_translation is undefined")
if (response_votes_translation == undefined) console.log("response_votes_translation is undefined")
if (response_h2h == undefined) console.log("response_h2h is undefined")
if (response_h2h_translation == undefined) console.log("response_h2h_translation is undefined")
if (response_fixtures_odds_translations == undefined) console.log("response_fixtures_odds_translations is undefined")
}

if (
response_fixtures_seo
&& response_fixtures_page_info
Expand All @@ -392,7 +415,7 @@ export async function load({
&& response_about_translation
&& response_votes_translation
&& response_probability_translation
&& response_h2h
// && response_h2h // IMPORTANT can be "NULL"
&& response_h2h_translation
// extra
&& response_fixtures_odds_translations
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
Loading