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

queries working #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified TeamInfo.md
100644 → 100755
Empty file.
Empty file modified data/gamehistory_k.csv
100644 → 100755
Empty file.
Empty file modified data/inventory.csv
100644 → 100755
Empty file.
Empty file modified data/kaggle_ds.csv
100644 → 100755
Empty file.
Empty file modified data/room.csv
100644 → 100755
Empty file.
Empty file modified data/skin.csv
100644 → 100755
Empty file.
Empty file modified data/transaction.csv
100644 → 100755
Empty file.
Empty file modified data/user.csv
100644 → 100755
Empty file.
Empty file modified doc/ConceuptalDatabaseDesign.md
100644 → 100755
Empty file.
Empty file modified doc/DatabaseDesign.md
100644 → 100755
Empty file.
Empty file modified doc/ProjectProposal.md
100644 → 100755
Empty file.
Empty file modified doc/StageRevisions.md
100644 → 100755
Empty file.
Empty file modified doc/UMLDiagram.md
100644 → 100755
Empty file.
Empty file modified doc/imgs/connection.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query1.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query1_1.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query1_2.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query1_3.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query1_4.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query1_5.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query1pre.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query2.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query2_1.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query2_2.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query2_3.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query2pre.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query3.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query3_1.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query3_2.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query3_3.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query3_4.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query3_5.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query3_6.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query3_7.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query3pre.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query4.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query4_1.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query4_2.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/imgs/query4_3.png
100644 → 100755
Empty file modified doc/imgs/query4_4.png
100644 → 100755
Empty file modified doc/imgs/query4_5.png
100644 → 100755
Empty file modified doc/imgs/query4_6.png
100644 → 100755
Empty file modified doc/imgs/query4pre.png
100644 → 100755
Empty file modified doc/imgs/query5.png
100644 → 100755
Empty file modified doc/imgs/query5_1.png
100644 → 100755
Empty file modified doc/imgs/query5_2.png
100644 → 100755
Empty file modified doc/imgs/query5_3.png
100644 → 100755
Empty file modified doc/imgs/query5pre.png
100644 → 100755
Empty file modified doc/imgs/rowCounts.png
100644 → 100755
Empty file modified doc/imgs/ui_mockup.png
100644 → 100755
Empty file modified doc/imgs/uml_diagram.png
100644 → 100755
Empty file modified doc/old/PT1_Stage_1_ProjectProposal.pdf
100644 → 100755
Empty file.
Empty file modified doc/old/PT1_Stage_2.pdf
100644 → 100755
Empty file.
Empty file modified doc/old/uml_diagram.pdf
100644 → 100755
Empty file.
Empty file modified gambit-gallery/.editorconfig
100644 → 100755
Empty file.
Empty file modified gambit-gallery/.gitignore
100644 → 100755
Empty file.
Empty file modified gambit-gallery/.vscode/extensions.json
100644 → 100755
Empty file.
Empty file modified gambit-gallery/.vscode/launch.json
100644 → 100755
Empty file.
Empty file modified gambit-gallery/.vscode/tasks.json
100644 → 100755
Empty file.
75 changes: 75 additions & 0 deletions gambit-gallery/backend/app.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,13 +1,88 @@
from flask import Flask, jsonify
from flask_cors import CORS
import mysql.connector

app = Flask(__name__)
CORS(app) # Enable CORS for cross-origin requests

connection = mysql.connector.connect(
host="34.41.165.201",
user="root",
password="GambitGallery!",
database="gambit_gallery"
)
cursor = connection.cursor()

queries = {
"UP": '''
SELECT UserID, action, AVG(balance) AS AvgBalance, SUM(CASE WHEN balance > 0 THEN 1 ELSE 0 END) / COUNT(balance) AS WinRate
FROM
(SELECT UserID, balance, action_pre AS action
FROM GameHistory
UNION ALL
SELECT UserID, balance, action_flop AS action
FROM GameHistory
UNION ALL
SELECT UserID, balance, action_turn AS action
FROM GameHistory
UNION ALL
SELECT UserID, balance, action_river AS action
FROM GameHistory) AS T
GROUP BY action, UserID
ORDER BY UserID, WinRate DESC''',
"CPW" : '''
SELECT UserID, Image
FROM (SELECT * FROM Account WHERE RoomID = 0) AS UserInRooms
JOIN Skin ON SkinID = CurrentSkin''',
"AT" : '''
SELECT g.UserID, g.Date, g.GameCount, t.NonGameCount, g.GameCount + t.NonGameCount AS TotalActivity
FROM
(SELECT UserID, DATE(DateTime) AS Date, COUNT(*) AS GameCount
FROM GameHistory
GROUP BY UserID, DATE(DateTime)) AS g
JOIN
(SELECT DISTINCT UserID, Date, COUNT(*) AS NonGameCount
FROM
((SELECT SenderID AS UserID, DATE(DateTime) AS Date
FROM Transaction
WHERE SenderID <> 'TEXAS_HOLDEM')
UNION ALL
(SELECT ReceiverID AS UserID, DATE(DateTime) AS Date
FROM Transaction
WHERE ReceiverID <> 'TEXAS_HOLDEM' )) AS CombinedTransactions
GROUP BY UserId, Date) AS t
ON g.UserID = t.UserID AND g.Date = t.Date
ORDER BY g.Date''',
'GCF' : '''
SELECT TransactionID, SenderID, ReceiverID, Amount, CONVERT(DateTime, DATE) AS TransactionDate
FROM Transaction
WHERE SenderID = 'TEXAS_HOLDEM' OR ReceiverID = 'TEXAS_HOLDEM'
GROUP BY TransactionDate, TransactionID, SenderID, ReceiverID, Amount''',
'RS' : '''
SELECT
UserID,
SUM(CASE WHEN balance > 0 THEN 1 ELSE 0 END) AS Positive,
SUM(CASE WHEN balance < 0 THEN 1 ELSE 0 END) AS Negative,
SUM(CASE WHEN balance = 0 THEN 1 ELSE 0 END) AS Zero
FROM GameHistory
WHERE handID IN ( SELECT handID
FROM GameHistory g
WHERE g.UserID LIKE "00021ae5")
GROUP BY UserID''',
}

@app.route('/api/hello', methods=['GET'])
def hello():
return jsonify({"message": "Hello from Flask!"})


@app.route('/api/query/<q>', methods=['GET'])
def query(q):
cursor.execute(queries[q])
return jsonify({"query": cursor.fetchall()})



if __name__ == '__main__':
app.run(debug=True, port=5000)

Empty file modified gambit-gallery/frontend/.editorconfig
100644 → 100755
Empty file.
Empty file modified gambit-gallery/frontend/.gitignore
100644 → 100755
Empty file.
Empty file modified gambit-gallery/frontend/.vscode/extensions.json
100644 → 100755
Empty file.
Empty file modified gambit-gallery/frontend/.vscode/launch.json
100644 → 100755
Empty file.
Empty file modified gambit-gallery/frontend/.vscode/tasks.json
100644 → 100755
Empty file.
Empty file modified gambit-gallery/frontend/README.md
100644 → 100755
Empty file.
Empty file modified gambit-gallery/frontend/angular.json
100644 → 100755
Empty file.
Loading