-
Notifications
You must be signed in to change notification settings - Fork 33
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
14 changed files
with
346 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ _private.js | |
_private.json | ||
a_private.go | ||
banned.list | ||
codetabsData.db3 | ||
*.db3 | ||
# | ||
|
||
# | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
github.com/ip2location/ip2location-go/v9 v9.1.0 h1:DVlKxIcjA7CsA0cgzbidwe6eKzpbkS313LsH9ceutxI= | ||
github.com/ip2location/ip2location-go/v9 v9.1.0/go.mod h1:s5SV6YZL10TpfPpXw//7fEJC65G/yH7Oh+Tjq9JcQEQ= | ||
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= | ||
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* */ | ||
|
||
package store | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"log" | ||
"time" | ||
|
||
u "github.com/jolav/codetabs/_utils" | ||
) | ||
|
||
type dataLoc struct { | ||
Repo string `json:"repo"` | ||
Source string `json:"source"` | ||
Date string `json:"date"` | ||
Data string `json:"data"` | ||
} | ||
|
||
func (d dataLoc) SaveDataLoc() { | ||
d.replaceLoc() | ||
//LoadDataLoc(d) | ||
} | ||
|
||
func (d dataLoc) replaceLoc() { | ||
sql := fmt.Sprintf("REPLACE INTO %s (repo, source, date, data) VALUES (?, ?, ?, ?)", | ||
locTable) | ||
stmt, err := MyDB.Prepare(sql) | ||
if err != nil { | ||
log.Printf("Error DB 1 replaceLoc => %s\n", err) | ||
return | ||
} | ||
defer stmt.Close() | ||
|
||
_, err = stmt.Exec(d.Repo, d.Source, d.Date, d.Data) | ||
if err != nil { | ||
log.Printf("Error DB 2 replaceLoc => %s\n", err) | ||
return | ||
} | ||
} | ||
|
||
func (d dataLoc) LoadDataLoc() { | ||
type languageOUT struct { | ||
Name string `json:"language"` | ||
Files int `json:"files"` | ||
Lines int `json:"lines"` | ||
Blanks int `json:"blanks"` | ||
Comments int `json:"comments"` | ||
Code int `json:"linesOfCode"` | ||
} | ||
var languagesOUT []languageOUT | ||
err := json.Unmarshal([]byte(d.Data), &languagesOUT) | ||
if err != nil { | ||
log.Printf("ERROR LoadConfig %s\n", err) | ||
} | ||
u.PrettyPrintStruct(languagesOUT) | ||
} | ||
|
||
func NewDataLoc() dataLoc { | ||
d := dataLoc{ | ||
Repo: "", | ||
Source: "", | ||
Date: time.Now().Format("2006-01-02 15:04:05.000"), | ||
Data: "{}", | ||
} | ||
return d | ||
} |
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,67 @@ | ||
/* */ | ||
|
||
package store | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"log" | ||
"time" | ||
|
||
u "github.com/jolav/codetabs/_utils" | ||
) | ||
|
||
type dataStars struct { | ||
Repo string `json:"repo"` | ||
Source string `json:"source"` | ||
Date string `json:"date"` | ||
Total int `json:"total"` | ||
Data string `json:"data"` | ||
} | ||
|
||
func (d dataStars) SaveDataStars() { | ||
d.replaceStars() | ||
//LoadDataStars(d) | ||
|
||
} | ||
|
||
func (d dataStars) replaceStars() { | ||
sql := fmt.Sprintf("REPLACE INTO %s (repo, source, date, total, data) VALUES (?, ?, ?, ?, ?)", | ||
starsTable) | ||
stmt, err := MyDB.Prepare(sql) | ||
if err != nil { | ||
log.Printf("Error DB 1 replaceStars => %s\n", err) | ||
return | ||
} | ||
defer stmt.Close() | ||
|
||
_, err = stmt.Exec(d.Repo, d.Source, d.Date, d.Total, d.Data) | ||
if err != nil { | ||
log.Printf("Error DB 2 replaceStars => %s\n", err) | ||
return | ||
} | ||
} | ||
|
||
func (d dataStars) LoadDataStars() { | ||
type point struct { | ||
When string `json:"x"` | ||
Quantity int `json:"y"` | ||
} | ||
var data []point | ||
err := json.Unmarshal([]byte(d.Data), &data) | ||
if err != nil { | ||
log.Printf("ERROR LoadConfig %s\n", err) | ||
} | ||
u.PrettyPrintStruct(data) | ||
} | ||
|
||
func NewDataStars() dataStars { | ||
d := dataStars{ | ||
Repo: "", | ||
Source: "", | ||
Date: time.Now().Format("2006-01-02 15:04:05.000"), | ||
Total: 0, | ||
Data: "{}", | ||
} | ||
return d | ||
} |
Oops, something went wrong.