automated terminal push

This commit is contained in:
Your Name
2025-02-06 12:51:43 -05:00
parent 1c87bf5906
commit 9a787b2a58
18 changed files with 772 additions and 0 deletions

11
.dockerignore Normal file
View File

@@ -0,0 +1,11 @@
volumes/
.git
.pristine
.trash
.recycle
.backup

17
Dockerfile Normal file
View File

@@ -0,0 +1,17 @@
FROM maven:3.8.7-openjdk-18-slim AS mavenBuild
WORKDIR /
COPY . .
RUN mvn install -DskipTests
FROM eclipse-temurin:18-jre-alpine
COPY --from=mavenBuild /target/yankee-twitch-data-api-1.0.jar /yankee-twitch-data-api.jar
COPY --from=mavenBuild /src/main/resources/application.properties /application.properties
COPY --from=mavenBuild /src/main/resources/eighteen.stub.html /eighteen.stub.html
CMD ["java", "-jar", "/yankee-twitch-data-api.jar"]

32
compose.bash Normal file
View File

@@ -0,0 +1,32 @@
#!/bin/bash
##
set -e
set -x
##
reset
clear
##
echo
echo "STARTED / yankee / twitchtracker / channel rankings"
echo
##
docker compose down --remove-orphans
#git pull
docker compose up --build -d
echo
echo "RUNNING / yankee / twitchtracker / channel rankings"
echo

158
compose.yaml Normal file
View File

@@ -0,0 +1,158 @@
services:
##########################################
##
## aventador / network
##
##########################################
aventador-proxy:
container_name: aventador-proxy
image: nginxproxy/nginx-proxy:1.6
restart: unless-stopped
ports:
- 80:80
- 443:443
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- /var/docker/nginx/html:/usr/share/nginx/html
- /var/docker/nginx/certs:/etc/nginx/certs
- /var/docker/nginx/vhost:/etc/nginx/vhost.d
logging:
options:
max-size: "10m"
max-file: "3"
aventador-letsencrypt:
container_name: aventador-letsencrypt
image: jrcs/letsencrypt-nginx-proxy-companion
restart: unless-stopped
volumes_from:
- aventador-proxy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/docker/nginx/acme:/etc/acme.sh
environment:
DEFAULT_EMAIL: embanet@gmail.com
##
## relational database server
##
## (vanilla mariadb w/ shinobi academy training db option)
##
yankee-database-server:
container_name: yankee-database-server
image: softwareshinobi/shinobi-academy-database-server
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: aggiepride
MYSQL_DATABASE: yankee
MYSQL_USER: yankee
MYSQL_PASSWORD: yankee
##
## web assessible query tool sitting on top of the database server
##
yankee-database-query:
container_name: yankee-database-query
image: beeyev/phpmyadmin-lightweight
ports:
- "3380:80"
depends_on:
- yankee-database-server
links:
- yankee-database-server
environment:
PMA_HOST: yankee-database-server:3306
VIRTUAL_HOST: database.yankee.embanet.online
LETSENCRYPT_HOST: database.yankee.embanet.online
####
##
## central computing for all yankee operations
##
yankee-twitch-data-api:
container_name: yankee-twitch-data-api
image: valorantdigital/yankee-twitch-data-api
depends_on:
- yankee-database-server
restart: unless-stopped
ports:
- 48888:8888
environment:
DB_HOST: yankee-database-server
DB_PORT: 3306
DB_NAME: yankee
DB_USER: yankee
DB_PASS: yankee
VIRTUAL_PORT: 8888
VIRTUAL_HOST: apis.yankee.embanet.online
LETSENCRYPT_HOST: apis.yankee.embanet.online

View File

@@ -0,0 +1,14 @@
# API
http://localhost:8888/twitch/channel/truncate
## load the top 1000
go get 50x rankings, 20 times. truncates before all operations.
localhost:8888/twitchtracker.com/channel/load/
##
http://localhost:8888/twitchtracker.com/channel/load/2
load page two of the rankings

View File

@@ -0,0 +1,65 @@
# TwitchTrackerStubController API Documentation
This document outlines the functionalities provided by the `TwitchTrackerStubController` class.
**Note:** This API provides stubbed data, meaning it simulates real data from `twitchtracker.com` but doesn't interact with the actual website.
**Base URL:** `http://localhost:8888/twitchtracker.com/channel/stub`
**CORS:** Enabled
### Endpoints
#### 1. GET /rankings
* **Description:** This endpoint retrieves a single page (50 channels) of stubbed Twitch channel rankings data.
* **Response:** String containing HTML data representing the rankings table.
**Example Usage:**
```
GET http://localhost:8888/twitchtracker.com/channel/stub/rankings
```
#### 2. GET /load/
* **Description:** This endpoint fetches and returns a list of 1000 stubbed Twitch channels with their rankings.
* **Response:** List of `TwitchChannel` objects containing channel information.
**Example Usage:**
```
GET http://localhost:8888/twitchtracker.com/channel/stub/load/
```
**Implementation Details:**
* This endpoint calculates the number of pages required to retrieve 1000 channels based on the `channelsPerTwitchTrackerPage` constant (default 50).
* It then iterates through each page number and calls the `loadSingleTwitchTrackerPageByNumber` endpoint to retrieve the data.
* Finally, it combines all retrieved channels into a single list and returns it.
#### 3. GET /load/{pageNumber}
* **Description:** This endpoint retrieves a single page (50 channels) of stubbed Twitch channel rankings data based on the provided page number.
* **Path Variable:** `pageNumber` (integer) - Specifies the desired page number.
* **Response:** List of `TwitchChannel` objects containing channel information for the requested page.
**Example Usage:**
```
GET http://localhost:8888/twitchtracker.com/channel/stub/load/2
```
**Implementation Details:**
* This endpoint fetches a single page of stubbed HTML data representing the rankings table.
* It then parses the HTML and converts it into a list of `TwitchChannel` objects using the `twitchTrackerService.convert_html_list_twitch_channels` method.
* Finally, it saves each retrieved channel to the database using the `twitchChannelService.save` method. (This behavior might be specific to your application's use case.)
**Additional Notes:**
* The `sleepRandomly` method introduces a random delay between page fetches to simulate realistic network behavior.
* This documentation assumes familiarity with Spring annotations like `@GetMapping`, `@PathVariable`, and `@Autowired`.

40
docs/golive.md Normal file
View File

@@ -0,0 +1,40 @@
1. log in to linux server
2. clone repository
```
https://code.softwareshinobi.digital/yankee/twitchtracker-channel-rankings.git
``
3. go into directory
4.
docker compose.bash
it is assumed you already have docker installerd.
so then run
```
sudo bash provision.bash
```
## load the fake data to spec first
http://aventador.embanet.softwareshinobi.digital:48888/twitchtracker.com/channel/stub/load/
## populate the sql query to load the view
## database loging
phpmyadmin, lets you manage shit inside the db.
url :
user:
pass:

17
docs/index.md Normal file
View File

@@ -0,0 +1,17 @@
# Welcome to MkDocs
For full documentation visit [mkdocs.org](https://www.mkdocs.org).
## Commands
* `mkdocs new [dir-name]` - Create a new project.
* `mkdocs serve` - Start the live-reloading docs server.
* `mkdocs build` - Build the documentation site.
* `mkdocs -h` - Print help message and exit.
## Project layout
mkdocs.yml # The configuration file.
docs/
index.md # The documentation homepage.
... # Other markdown pages, images and other files.

9
docs/license.md Normal file
View File

@@ -0,0 +1,9 @@
MIT License
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

25
docs/view.sql.md Normal file
View File

@@ -0,0 +1,25 @@
# the view for custom reporting
## Create the View
```
## Drop the view
DROP VIEW IF EXISTS report_twitchdata_top_1500_channels;
CREATE VIEW report_twitchdata_top_1500_channels AS
SELECT
`tag` "username",`url`,`logo` "logo_url", `all_time_peak_viewers`, `avg_viewers` "average_viewers", `followers_gained`, `hours_streamed`, `hours_watched`, `rank`, `total_followers`,
CASE
WHEN total_views = -1 THEN 'null'
ELSE total_views
END AS total_views
from twitch_channel;
-- Select data from the view
SELECT * FROM report_twitchdata_top_1500_channels;
```

98
gemini Normal file
View File

@@ -0,0 +1,98 @@
package com.example.filedownload.model;
import jakarta.persistence.*;
import java.time.LocalDateTime;
@Entity
@Table(name = "file_downloads")
public class FileDownload {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String url;
@Column(nullable = false)
private String hostIp;
@Column(nullable = false)
private LocalDateTime dateTime;
// Constructors, getters and setters
}
package com.example.filedownload.service;
import com.example.filedownload.model.FileDownload;
import com.example.filedownload.repository.FileDownloadRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
@Service
public class FileDownloadService {
@Autowired
private FileDownloadRepository fileDownloadRepository;
public FileDownload save(String url, String hostIp) {
FileDownload fileDownload = new FileDownload();
fileDownload.setUrl(url);
fileDownload.setHostIp(hostIp);
fileDownload.setDateTime(LocalDateTime.now());
return fileDownloadRepository.save(fileDownload);
}
}
package com.example.filedownload.service;
import com.example.filedownload.model.FileDownload;
import com.example.filedownload.repository.FileDownloadRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
@Service
public class FileDownloadService {
@Autowired
private FileDownloadRepository fileDownloadRepository;
public FileDownload save(String url, String hostIp) {
FileDownload fileDownload = new FileDownload();
fileDownload.setUrl(url);
fileDownload.setHostIp(hostIp);
fileDownload.setDateTime(LocalDateTime.now());
return fileDownloadRepository.save(fileDownload);
}
}
package com.example.filedownload.controller;
import com.example.filedownload.model.FileDownload;
import com.example.filedownload.service.FileDownloadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class FileDownloadController {
@Autowired
private FileDownloadService fileDownloadService;
@GetMapping("/doesexist/{url}")
public boolean doesExist(@PathVariable String url) {
String fullUrl = "google.com/" + url; // Assuming "google.com" is the base URL
return fileDownloadService.existsByUrl(fullUrl);
}
}

55
nbactions.xml Normal file
View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>run</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:3.1.0:exec</goal>
</goals>
<properties>
<exec.vmArgs>-DDB_HOST=aventador.embanet.online -DDB_PORT=3306 -DDB_NAME=aventador -DDB_USER=aventador -DDB_PASS=aventador</exec.vmArgs>
<exec.args>${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}</exec.args>
<exec.appArgs></exec.appArgs>
<exec.mainClass>edu.gsyoung.twitch.TwitchDataAcquisition</exec.mainClass>
<exec.executable>java</exec.executable>
</properties>
</action>
<action>
<actionName>debug</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:3.1.0:exec</goal>
</goals>
<properties>
<exec.vmArgs>-DDB_HOST=aventador.embanet.online -DDB_PORT=3306 -DDB_NAME=aventador -DDB_USER=aventador -DDB_PASS=aventador -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}</exec.vmArgs>
<exec.args>${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}</exec.args>
<exec.appArgs></exec.appArgs>
<exec.mainClass>edu.gsyoung.twitch.TwitchDataAcquisition</exec.mainClass>
<exec.executable>java</exec.executable>
<jpda.listen>true</jpda.listen>
</properties>
</action>
<action>
<actionName>profile</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:3.1.0:exec</goal>
</goals>
<properties>
<exec.vmArgs>-DDB_HOST=aventador.embanet.online -DDB_PORT=3306 -DDB_NAME=aventador -DDB_USER=aventador -DDB_PASS=aventador</exec.vmArgs>
<exec.args>${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}</exec.args>
<exec.mainClass>edu.gsyoung.twitch.TwitchDataAcquisition</exec.mainClass>
<exec.executable>java</exec.executable>
<exec.appArgs></exec.appArgs>
</properties>
</action>
</actions>

99
pom.xml Normal file
View File

@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.0</version>
<relativePath/>
</parent>
<groupId>edu.gsyoung</groupId>
<artifactId>yankee-twitch-data-api</artifactId>
<name>yankee-twitch-data-api</name>
<description>yankee-twitch-data-api</description>
<version>1.0</version>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

16
readme.md Normal file
View File

@@ -0,0 +1,16 @@
# twitch saas!
## sit rep
[DONE] the monthly stats data is loading but the repositories are all broken.
[NOW] now we need to enrich the html so that the js and the css load and properly render the page and render the table data
## later
fix all the repos
create the click page for the phase one activities
add a menu to the click page

View File

@@ -0,0 +1,49 @@
reset
clear
set -e
#set -x
##
echo
echo "##"
echo "##"
echo "##"
echo
##
curl -X GET http://localhost:8888/channel/monthly/games/failure/
sleep 4
echo
echo "##"
echo "##"
echo "##"
echo
curl -X GET \
http://localhost:8888/channel/monthly/games/failure/exists \
-H 'Content-Type: application/json' \
-d '{
"url": "https://links.embanet.com/talisman.txt"
}'
sleep 4
echo
echo "##"
echo "##"
echo "##"
echo
curl -X GET \
http://localhost:8888/channel/monthly/games/failure/exists \
-H 'Content-Type: application/json' \
-d '{
"url": "https://www.garudanet.com/talisman.txt"
}'

View File

@@ -0,0 +1,24 @@
#!/bin/bash
##
reset
clear
##
set -e
set -x
##
echo "##"
echo "## creating new [failure] record in the database"
echo "##"
curl -X POST \
http://localhost:8888/channel/monthly/games/failure/add \
-H 'Content-Type: application/json' \
-d '{"url": "https://www.garudanet.com/talisman.txt","hostIP":"falcon"}'

View File

@@ -0,0 +1,19 @@
echo "##"
echo "##"
echo "##"
curl -X GET https://osiris.yankee.valorantdigital.com/channel/monthly/games/success/
curl -X GET \
https://osiris.yankee.valorantdigital.com/channel/monthly/games/success/exists \
-H 'Content-Type: application/json' \
-d '{
"url": "https://www.embanet.com/talisman.txt"
}'
curl -X GET \
https://osiris.yankee.valorantdigital.com/channel/monthly/games/success/exists \
-H 'Content-Type: application/json' \
-d '{
"url": "https://www.embanet.com/talisman.md"
}'

View File

@@ -0,0 +1,24 @@
#!/bin/bash
##
reset
clear
##
set -e
set -x
##
echo "##"
echo "## creating new [success] record in the database"
echo "##"
curl -X POST \
https://osiris.yankee.valorantdigital.com/channel/monthly/games/success/add \
-H 'Content-Type: application/json' \
-d '{"url": "https://www.embanet.com/talisman.txt","hostIP":"asdf"}'