diff --git a/.legacy/.dockerignore b/.legacy/.dockerignore deleted file mode 100644 index eb1c207..0000000 --- a/.legacy/.dockerignore +++ /dev/null @@ -1,11 +0,0 @@ -volumes/ - -.git - -.pristine - -.trash - -.recycle - -.backup diff --git a/.legacy/.gitignore b/.legacy/.gitignore deleted file mode 100644 index c674098..0000000 --- a/.legacy/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -# ---> Linux -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - diff --git a/.legacy/Dockerfile b/.legacy/Dockerfile deleted file mode 100644 index e0cfff9..0000000 --- a/.legacy/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -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-gnome-twitch-api-1.0.jar /yankee-gnome-twitch-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-gnome-twitch-api.jar"] diff --git a/.legacy/README.md b/.legacy/README.md deleted file mode 100644 index 4b3499d..0000000 --- a/.legacy/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# yankee-gnome-twitch-api - -yankee-gnome-twitch-api!!!! \ No newline at end of file diff --git a/.legacy/compose.bash b/.legacy/compose.bash deleted file mode 100755 index c4e8597..0000000 --- a/.legacy/compose.bash +++ /dev/null @@ -1,32 +0,0 @@ -#!/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 diff --git a/.legacy/compose.yaml b/.legacy/compose.yaml deleted file mode 100644 index 2e5e272..0000000 --- a/.legacy/compose.yaml +++ /dev/null @@ -1,91 +0,0 @@ -services: - - yankee-gnome-twitch-api: - - container_name: yankee-gnome-twitch-api - - image: valorantdigital/yankee-gnome-twitch-api - - build: - - context: . - - dockerfile: Dockerfile - - restart: unless-stopped - - ports: - - - 8888: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 - -########################################## -## -## veneno / relational data -## -########################################## - - veneno-database: - - container_name: veneno-database - - image: mariadb:latest - - restart: unless-stopped - - ports: - - - "3306:3306" - - environment: - - MYSQL_ROOT_PASSWORD: aggiepride - - MYSQL_DATABASE: yankee_gnome_twitch - - MYSQL_USER: yankee_gnome_twitch - - MYSQL_PASSWORD: yankee_gnome_twitch - - volumes: - - - /yankee/volumes/database:/var/lib/mysql - - veneno-phpmyadmin: - - container_name: veneno-phpmyadmin - - image: beeyev/phpmyadmin-lightweight - - depends_on: - - - veneno-database - - links: - - - veneno-database - - environment: - - PMA_HOST: veneno-database - - VIRTUAL_HOST: database.yankee.embanet.online - - LETSENCRYPT_HOST: database.yankee.embanet.online diff --git a/.legacy/docs/api/twitch/channel.md b/.legacy/docs/api/twitch/channel.md deleted file mode 100644 index fdc7713..0000000 --- a/.legacy/docs/api/twitch/channel.md +++ /dev/null @@ -1,14 +0,0 @@ -# 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 diff --git a/.legacy/docs/api/twitch/twitchdata.com/stub.md b/.legacy/docs/api/twitch/twitchdata.com/stub.md deleted file mode 100644 index 912b87c..0000000 --- a/.legacy/docs/api/twitch/twitchdata.com/stub.md +++ /dev/null @@ -1,65 +0,0 @@ -# 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`. - - diff --git a/.legacy/docs/golive.md b/.legacy/docs/golive.md deleted file mode 100644 index b67f383..0000000 --- a/.legacy/docs/golive.md +++ /dev/null @@ -1,40 +0,0 @@ - -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: diff --git a/.legacy/docs/index.md b/.legacy/docs/index.md deleted file mode 100644 index 000ea34..0000000 --- a/.legacy/docs/index.md +++ /dev/null @@ -1,17 +0,0 @@ -# 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. diff --git a/.legacy/docs/license.md b/.legacy/docs/license.md deleted file mode 100644 index 2071b23..0000000 --- a/.legacy/docs/license.md +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) - -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. diff --git a/.legacy/docs/view.sql.md b/.legacy/docs/view.sql.md deleted file mode 100644 index fbd76d6..0000000 --- a/.legacy/docs/view.sql.md +++ /dev/null @@ -1,25 +0,0 @@ -# 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; - - -``` diff --git a/.legacy/gemini b/.legacy/gemini deleted file mode 100644 index 3b79f24..0000000 --- a/.legacy/gemini +++ /dev/null @@ -1,98 +0,0 @@ -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); - } -} diff --git a/.legacy/nbactions.xml b/.legacy/nbactions.xml deleted file mode 100644 index c2fc1f6..0000000 --- a/.legacy/nbactions.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - run - - jar - - - process-classes - org.codehaus.mojo:exec-maven-plugin:3.1.0:exec - - - -DDB_HOST=aventador.embanet.online -DDB_PORT=3306 -DDB_NAME=aventador -DDB_USER=aventador -DDB_PASS=aventador - ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs} - - edu.gsyoung.twitch.TwitchDataAcquisition - java - - - - debug - - jar - - - process-classes - org.codehaus.mojo:exec-maven-plugin:3.1.0:exec - - - -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} -classpath %classpath ${exec.mainClass} ${exec.appArgs} - - edu.gsyoung.twitch.TwitchDataAcquisition - java - true - - - - profile - - jar - - - process-classes - org.codehaus.mojo:exec-maven-plugin:3.1.0:exec - - - -DDB_HOST=aventador.embanet.online -DDB_PORT=3306 -DDB_NAME=aventador -DDB_USER=aventador -DDB_PASS=aventador - ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs} - edu.gsyoung.twitch.TwitchDataAcquisition - java - - - - diff --git a/.legacy/pom.xml b/.legacy/pom.xml deleted file mode 100644 index 7a73ada..0000000 --- a/.legacy/pom.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - 4.0.0 - - - - org.springframework.boot - - spring-boot-starter-parent - - 3.1.0 - - - - - - edu.gsyoung - - yankee-twitch-data-api - - yankee-twitch-data-api - - yankee-twitch-data-api - - 1.0 - - - - 17 - - - - - - - org.jsoup - jsoup - 1.13.1 - jar - - - - org.springframework.boot - spring-boot-starter-actuator - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - - org.springframework.boot - spring-boot-starter-validation - - - - org.springframework.boot - spring-boot-starter-web - - - - org.projectlombok - lombok - true - - - - org.mariadb.jdbc - mariadb-java-client - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - org.projectlombok - lombok - - - - - - - - diff --git a/.legacy/readme.md b/.legacy/readme.md deleted file mode 100644 index 0eccaf7..0000000 --- a/.legacy/readme.md +++ /dev/null @@ -1,16 +0,0 @@ -# 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 diff --git a/.legacy/test/failure/eval-failure-check-exists.bash b/.legacy/test/failure/eval-failure-check-exists.bash deleted file mode 100644 index cd10234..0000000 --- a/.legacy/test/failure/eval-failure-check-exists.bash +++ /dev/null @@ -1,49 +0,0 @@ -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" -}' diff --git a/.legacy/test/failure/eval-failure-create-new.bash b/.legacy/test/failure/eval-failure-create-new.bash deleted file mode 100644 index 59517fb..0000000 --- a/.legacy/test/failure/eval-failure-create-new.bash +++ /dev/null @@ -1,24 +0,0 @@ -#!/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"}' diff --git a/.legacy/test/success/eval-success-check-exists.bash b/.legacy/test/success/eval-success-check-exists.bash deleted file mode 100644 index 866dd0b..0000000 --- a/.legacy/test/success/eval-success-check-exists.bash +++ /dev/null @@ -1,19 +0,0 @@ -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" -}' diff --git a/.legacy/test/success/eval-success-create-new.bash b/.legacy/test/success/eval-success-create-new.bash deleted file mode 100644 index 9a27136..0000000 --- a/.legacy/test/success/eval-success-create-new.bash +++ /dev/null @@ -1,24 +0,0 @@ -#!/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"}' diff --git a/Jenkinsfile b/Jenkinsfile old mode 100755 new mode 100644 diff --git a/compose.yaml b/compose.yaml index 35ab33b..ee99e0b 100644 --- a/compose.yaml +++ b/compose.yaml @@ -16,7 +16,7 @@ services: ports: - - 8888:8888 + - 18888:8888 environment: @@ -58,15 +58,16 @@ services: MYSQL_ROOT_PASSWORD: aggiepride - MYSQL_DATABASE: yankee_gnome_twitch + MYSQL_DATABASE: veneno - MYSQL_USER: yankee_gnome_twitch + MYSQL_USER: veneno - MYSQL_PASSWORD: yankee_gnome_twitch + MYSQL_PASSWORD: veneno - volumes: - - - /yankee/volumes/database:/var/lib/mysql +## volumes: +## +## - /tmp/yankee/volumes/database:/var/lib/mysql +## veneno-phpmyadmin: @@ -82,6 +83,10 @@ services: - veneno-database + ports: + + - "3380:80" + environment: PMA_HOST: veneno-database diff --git a/nbactions.xml b/nbactions.xml index c2fc1f6..529901c 100644 --- a/nbactions.xml +++ b/nbactions.xml @@ -10,7 +10,7 @@ org.codehaus.mojo:exec-maven-plugin:3.1.0:exec - -DDB_HOST=aventador.embanet.online -DDB_PORT=3306 -DDB_NAME=aventador -DDB_USER=aventador -DDB_PASS=aventador + -DDB_HOST=localhost -DDB_PORT=3306 -DDB_NAME=veneno -DDB_USER=veneno -DDB_PASS=veneno ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs} edu.gsyoung.twitch.TwitchDataAcquisition @@ -27,7 +27,7 @@ org.codehaus.mojo:exec-maven-plugin:3.1.0:exec - -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} + -DDB_HOST=localhost -DDB_PORT=3306 -DDB_NAME=veneno -DDB_USER=veneno -DDB_PASS=veneno -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs} edu.gsyoung.twitch.TwitchDataAcquisition @@ -45,7 +45,7 @@ org.codehaus.mojo:exec-maven-plugin:3.1.0:exec - -DDB_HOST=aventador.embanet.online -DDB_PORT=3306 -DDB_NAME=aventador -DDB_USER=aventador -DDB_PASS=aventador + -DDB_HOST=localhost -DDB_PORT=3306 -DDB_NAME=veneno -DDB_USER=veneno -DDB_PASS=veneno ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs} edu.gsyoung.twitch.TwitchDataAcquisition java diff --git a/src/main/java/edu/gsyoung/twitch/upstream/sullygnome/download/failure/SullyDownloadFailure.java b/src/main/java/edu/gsyoung/twitch/upstream/sullygnome/download/failure/SullyDownloadFailure.java index d3e7a1a..6560442 100644 --- a/src/main/java/edu/gsyoung/twitch/upstream/sullygnome/download/failure/SullyDownloadFailure.java +++ b/src/main/java/edu/gsyoung/twitch/upstream/sullygnome/download/failure/SullyDownloadFailure.java @@ -1,6 +1,7 @@ package edu.gsyoung.twitch.upstream.sullygnome.download.failure; import jakarta.persistence.*; +import java.sql.Timestamp; @Entity @Table(name = "sully_download_failure") @@ -10,12 +11,26 @@ public class SullyDownloadFailure { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @Column(nullable = false) + @Column(name = "download_url", nullable = false) private String url; - @Column(nullable = false) + @Column(name = "reason", nullable = false) + private String reason; + + @Column(name = "host_ip", nullable = false) private String hostIP; + @Column(name = "host_name", nullable = false) + private String hostName; + + @Column(name = "insert_date", nullable = false, updatable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") + @Temporal(TemporalType.TIMESTAMP) + private Timestamp insertDate; + + @Column(name = "update_date", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") + @Temporal(TemporalType.TIMESTAMP) + private Timestamp updateDate; + public Long getId() { return id; @@ -52,23 +67,50 @@ public class SullyDownloadFailure { } - @Override - public String toString() { - - StringBuilder stringBuilder = new StringBuilder(); - - stringBuilder.append("SullyDownloadFailure{"); - - stringBuilder.append("id=").append(id); - - stringBuilder.append(", url=").append(url); - - stringBuilder.append(", hostIp=").append(hostIP); - - stringBuilder.append('}'); - - return stringBuilder.toString(); - + public String getHostName() { + return hostName; } -} + public void setHostName(String hostName) { + this.hostName = hostName; + } + + public Timestamp getInsertDate() { + return insertDate; + } + + public void setInsertDate(Timestamp insertDate) { + this.insertDate = insertDate; + } + + public Timestamp getUpdateDate() { + return updateDate; + } + + public void setUpdateDate(Timestamp updateDate) { + this.updateDate = updateDate; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("SullyDownloadFailure{"); + sb.append("id=").append(id); + sb.append(", url=").append(url); + sb.append(", reason=").append(reason); + sb.append(", hostIP=").append(hostIP); + sb.append(", hostName=").append(hostName); + sb.append(", insertDate=").append(insertDate); + sb.append(", updateDate=").append(updateDate); + sb.append('}'); + return sb.toString(); + } + + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } +} \ No newline at end of file diff --git a/src/main/java/edu/gsyoung/twitch/upstream/sullygnome/download/success/SullyDownloadSuccess.java b/src/main/java/edu/gsyoung/twitch/upstream/sullygnome/download/success/SullyDownloadSuccess.java index f3133b0..f81cb5e 100644 --- a/src/main/java/edu/gsyoung/twitch/upstream/sullygnome/download/success/SullyDownloadSuccess.java +++ b/src/main/java/edu/gsyoung/twitch/upstream/sullygnome/download/success/SullyDownloadSuccess.java @@ -1,6 +1,7 @@ package edu.gsyoung.twitch.upstream.sullygnome.download.success; import jakarta.persistence.*; +import java.sql.Timestamp; @Entity @Table(name = "sully_download_success") @@ -10,12 +11,23 @@ public class SullyDownloadSuccess { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @Column(nullable = false) + @Column(name = "download_url", nullable = false) private String url; - @Column(nullable = false) + @Column(name = "host_ip", nullable = false) private String hostIP; + @Column(name = "host_name", nullable = false) + private String hostName; + + @Column(name = "insert_date", nullable = false, updatable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") + @Temporal(TemporalType.TIMESTAMP) + private Timestamp insertDate; + + @Column(name = "update_date", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") + @Temporal(TemporalType.TIMESTAMP) + private Timestamp updateDate; + public Long getId() { return id; @@ -52,23 +64,42 @@ public class SullyDownloadSuccess { } + public String getHostName() { + return hostName; + } + + public void setHostName(String hostName) { + this.hostName = hostName; + } + + public Timestamp getInsertDate() { + return insertDate; + } + + public void setInsertDate(Timestamp insertDate) { + this.insertDate = insertDate; + } + + public Timestamp getUpdateDate() { + return updateDate; + } + + public void setUpdateDate(Timestamp updateDate) { + this.updateDate = updateDate; + } + @Override public String toString() { - - StringBuilder stringBuilder = new StringBuilder(); - - stringBuilder.append("SullyDownloadSuccess{"); - - stringBuilder.append("id=").append(id); - - stringBuilder.append(", url=").append(url); - - stringBuilder.append(", hostIp=").append(hostIP); - - stringBuilder.append('}'); - - return stringBuilder.toString(); - + StringBuilder sb = new StringBuilder(); + sb.append("SullyDownloadSuccess{"); + sb.append("id=").append(id); + sb.append(", url=").append(url); + sb.append(", hostIP=").append(hostIP); + sb.append(", hostName=").append(hostName); + sb.append(", insertDate=").append(insertDate); + sb.append(", updateDate=").append(updateDate); + sb.append('}'); + return sb.toString(); } } diff --git a/test/success/eval-failure-create-new.py b/test/success/eval-failure-create-new.py new file mode 100644 index 0000000..1a4e8d1 --- /dev/null +++ b/test/success/eval-failure-create-new.py @@ -0,0 +1,52 @@ +import requests +import json +import socket +import netifaces # For getting external IP (install with: pip install netifaces) + +def get_external_ip(): + """Gets the external IP address using a reliable service.""" + try: + response = requests.get("https://api.ipify.org?format=json", timeout=5) # Use a reliable service + response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx) + ip_data = response.json() + return ip_data["ip"] + except requests.exceptions.RequestException as e: + print(f"Error getting external IP: {e}") + return "0.0.0.0" # Or some other default value + +def get_hostname(): + """Gets the local hostname.""" + try: + return socket.gethostname() + except Exception as e: + print(f"Error getting hostname: {e}") + return "unknown_host" + +def create_success_record(url): + """Creates a new 'success' record in the database.""" + external_ip = get_external_ip() + hostname = get_hostname() + + data = { + "url": url, + "hostIP": external_ip, + "hostName": hostname + } + + try: + response = requests.post( + "http://localhost:8888/channel/monthly/games/failure/add", + headers={'Content-Type': 'application/json'}, + data=json.dumps(data) # Use json.dumps() to serialize the data + ) + response.raise_for_status() # Check for HTTP errors + print("Successfully created record:", response.json()) # Print the response from the server + except requests.exceptions.RequestException as e: + print(f"Error creating record: {e}") + except json.JSONDecodeError as e: + print(f"Error decoding JSON response: {e}") # Handle potential JSON decode errors + + +if __name__ == "__main__": + url = "https://www.embanet.com/talisman.txt" # Replace with your actual URL + create_success_record(url) \ No newline at end of file diff --git a/test/success/eval-success-create-new.bash b/test/success/eval-success-create-new.bash index 9a27136..505a586 100755 --- a/test/success/eval-success-create-new.bash +++ b/test/success/eval-success-create-new.bash @@ -18,7 +18,4 @@ 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"}' +curl -X POST http://localhost:8888/channel/monthly/games/success/add -H 'Content-Type: application/json' -d '{"url": "https://www.embanet.com/talisman.txt","hostIP":"asdf","hostName":"veneno"}' diff --git a/test/success/eval-success-create-new.py b/test/success/eval-success-create-new.py new file mode 100644 index 0000000..6d8b722 --- /dev/null +++ b/test/success/eval-success-create-new.py @@ -0,0 +1,52 @@ +import requests +import json +import socket +import netifaces # For getting external IP (install with: pip install netifaces) + +def get_external_ip(): + """Gets the external IP address using a reliable service.""" + try: + response = requests.get("https://api.ipify.org?format=json", timeout=5) # Use a reliable service + response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx) + ip_data = response.json() + return ip_data["ip"] + except requests.exceptions.RequestException as e: + print(f"Error getting external IP: {e}") + return "0.0.0.0" # Or some other default value + +def get_hostname(): + """Gets the local hostname.""" + try: + return socket.gethostname() + except Exception as e: + print(f"Error getting hostname: {e}") + return "unknown_host" + +def create_success_record(url): + """Creates a new 'success' record in the database.""" + external_ip = get_external_ip() + hostname = get_hostname() + + data = { + "url": url, + "hostIP": external_ip, + "hostName": hostname + } + + try: + response = requests.post( + "http://localhost:8888/channel/monthly/games/success/add", + headers={'Content-Type': 'application/json'}, + data=json.dumps(data) # Use json.dumps() to serialize the data + ) + response.raise_for_status() # Check for HTTP errors + print("Successfully created record:", response.json()) # Print the response from the server + except requests.exceptions.RequestException as e: + print(f"Error creating record: {e}") + except json.JSONDecodeError as e: + print(f"Error decoding JSON response: {e}") # Handle potential JSON decode errors + + +if __name__ == "__main__": + url = "https://www.embanet.com/talisman.txt" # Replace with your actual URL + create_success_record(url) \ No newline at end of file