-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
89 additions
and
142 deletions.
There are no files selected for viewing
This file contains 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 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 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,16 @@ | ||
import { Pool } from 'pg'; | ||
import dotenv from 'dotenv'; | ||
|
||
// Check the NODE_ENV and load the corresponding .env file | ||
const envFile = process.env.NODE_ENV === 'production' ? '.env' : '.env.local'; | ||
dotenv.config({ path: envFile }); | ||
|
||
const pool = new Pool({ | ||
user: process.env.DB_USER, | ||
host: process.env.DB_HOST, | ||
database: process.env.DB_NAME, | ||
password: process.env.DB_PASSWORD, | ||
port: process.env.DB_PORT ? parseInt(process.env.DB_PORT) : 5432, | ||
}); | ||
|
||
export default pool; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
17 changes: 9 additions & 8 deletions
17
packages/backend/src/services/fetchBattleReportsForPlanet.ts
This file contains 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,16 +1,17 @@ | ||
import supabase from "../config/supabaseClient"; | ||
import pool from '../config/db'; // Ensure you have the correct path to your db config | ||
|
||
export const fetchBattleReportsForPlanet = async (planetId: number) => { | ||
const { data, error } = await supabase.rpc("get_battle_reports_for_planet", { | ||
planet_id_param: planetId, | ||
}); | ||
try { | ||
// Assuming you have a stored procedure or a direct SQL query equivalent to 'get_battle_reports_for_planet' | ||
const queryText = 'SELECT * FROM get_battle_reports_for_planet($1);'; // or a SELECT query if it's not a procedure | ||
const values = [planetId]; | ||
|
||
if (error) { | ||
console.error("Error fetching battle reports:", error); | ||
const { rows } = await pool.query(queryText, values); | ||
return rows; | ||
} catch (error) { | ||
console.error('Error fetching battle reports:', error); | ||
return null; | ||
} | ||
|
||
return data; | ||
}; | ||
|
||
export default fetchBattleReportsForPlanet; |
This file contains 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,14 +1,16 @@ | ||
import supabase from "../config/supabaseClient"; | ||
import pool from '../config/db'; // Ensure you have the correct path to your db config | ||
|
||
export const fetchFleetLeaderboard = async () => { | ||
const { data, error } = await supabase.rpc("fetch_fleet_leaderboard"); | ||
try { | ||
// Assuming you have a stored procedure or a direct SQL query equivalent to 'fetch_fleet_leaderboard' | ||
const queryText = 'SELECT * FROM fetch_fleet_leaderboard();'; // or a SELECT query if it's not a procedure | ||
|
||
if (error) { | ||
console.error("Error fetching fleet leaderboard:", error); | ||
const { rows } = await pool.query(queryText); | ||
return rows; | ||
} catch (error) { | ||
console.error('Error fetching fleet leaderboard:', error); | ||
throw error; | ||
} | ||
|
||
return data; | ||
}; | ||
|
||
export default fetchFleetLeaderboard; |
This file contains 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,14 +1,16 @@ | ||
import supabase from "../config/supabaseClient"; | ||
import pool from '../config/db'; // Ensure you have the correct path to your db config | ||
|
||
export const fetchLeaderBoard = async () => { | ||
const { data, error } = await supabase.rpc("fetch_leaderboard"); // This is the name of your stored procedure | ||
try { | ||
// Assuming you have a stored procedure or a direct SQL query equivalent to 'fetch_fleet_leaderboard' | ||
const queryText = 'SELECT * FROM fetch_leaderboard();'; // or a SELECT query if it's not a procedure | ||
|
||
if (error) { | ||
console.error("Error fetching leaderboard:", error); | ||
const { rows } = await pool.query(queryText); | ||
return rows; | ||
} catch (error) { | ||
console.error('Error fetching leaderboard:', error); | ||
throw error; | ||
} | ||
|
||
return data; | ||
}; | ||
|
||
export default fetchLeaderBoard; |
This file contains 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,14 +1,16 @@ | ||
import supabase from "../config/supabaseClient"; | ||
import pool from '../config/db'; // Ensure you have the correct path to your db config | ||
|
||
export const fetchTechLeaderboard = async () => { | ||
const { data, error } = await supabase.rpc("fetch_tech_leaderboard"); | ||
try { | ||
// Assuming you have a stored procedure or a direct SQL query equivalent to 'fetch_fleet_leaderboard' | ||
const queryText = 'SELECT * FROM fetch_tech_leaderboard();'; // or a SELECT query if it's not a procedure | ||
|
||
if (error) { | ||
console.error("Error fetching fleet leaderboard:", error); | ||
const { rows } = await pool.query(queryText); | ||
return rows; | ||
} catch (error) { | ||
console.error('Error fetching tech leaderboard:', error); | ||
throw error; | ||
} | ||
|
||
return data; | ||
}; | ||
|
||
export default fetchTechLeaderboard; |
This file contains 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,14 +1,16 @@ | ||
import supabase from "../config/supabaseClient"; | ||
import pool from '../config/db'; | ||
|
||
export const fetchUniverse = async () => { | ||
const { data, error } = await supabase.rpc("get_universe"); // This is the name of your stored procedure | ||
try { | ||
// Assuming you have a stored procedure or a direct SQL query equivalent to 'fetch_fleet_leaderboard' | ||
const queryText = 'SELECT * FROM get_universe();'; // or a SELECT query if it's not a procedure | ||
|
||
if (error) { | ||
console.error("Error fetching universe:", error); | ||
const { rows } = await pool.query(queryText); | ||
return rows; | ||
} catch (error) { | ||
console.error('Error fetching universe:', error); | ||
throw error; | ||
} | ||
|
||
return data; | ||
}; | ||
|
||
export default fetchUniverse; |
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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 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 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 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