~jacksonchen666/quick_statement_generator_for_software_version_identifier

7c2e6774c53282d5619bd9789a961d98be002a9a — Jackson Chen 2 years ago e7ef06c
add test and detecting release types & formatting
3 files changed, 28 insertions(+), 8 deletions(-)

M TODO.md
M generators.go
M generators_test.go
M TODO.md => TODO.md +1 -1
@@ 1,3 1,3 @@
# features TODO
- [ ] add additional information to existing statements if not yet added
- [ ] detecting beta, pre-releases, and alpha releases (based on [this](https://github.com/Chocobozzz/PeerTube/releases/tag/v1.0.0-beta.9))
- [x] detecting beta, pre-releases, and alpha releases (based on [this](https://github.com/Chocobozzz/PeerTube/releases/tag/v1.0.0-beta.9))

M generators.go => generators.go +17 -7
@@ 28,6 28,7 @@ const (
	VersionTypeBeta             = "Q3295609"
	VersionTypeReleaseCandidate = "Q1072356"
	VersionTypeStable           = "Q2804309"
	VersionTypePreRelease       = "Q51930650"
)

var day_dur *time.Duration


@@ 64,7 65,7 @@ func RemoveAlreadyAdded(wikidataData *[]DestinationInfo, githubData *[]SourceInf
			_dataNotYetThere = append(_dataNotYetThere, i)
		}
	}
	return 
	return
}

/*


@@ 114,15 115,24 @@ func GenerateQSV1FromData(wikidataItem string, toAdd *[]SourceInfo, retrivedDate
		}
		published_date_string := published_date.Truncate(*day_dur).Format(iso8601Format)
		current_statement += fmt.Sprintf(`P577	+%s/11	`, published_date_string) // publish date
		release_type := VersionTypeStable
		if strings.Contains(i.Name, "rc") { // release candidate
		release_type := "" // is something in the future
		switch {
		case strings.Contains(i.Name, "rc"):
			release_type = VersionTypeReleaseCandidate
		case strings.Contains(i.Name, "pre"):
			release_type = VersionTypePreRelease
		case strings.Contains(i.Name, "beta"):
			release_type = VersionTypeBeta
		case strings.Contains(i.Name, "alpha"):
			release_type = VersionTypeAlpha
		default:
			release_type = VersionTypeStable
		}
		current_statement += fmt.Sprintf(`P548	%s	`, release_type) // the release type
		current_statement += fmt.Sprintf(`S854	"%s"	`, i.URL) // source link
		current_statement += fmt.Sprintf(`P548	%s	`, release_type)              // the release type
		current_statement += fmt.Sprintf(`S854	"%s"	`, i.URL)                   // source link
		current_statement += fmt.Sprintf(`S577	+%s/11	`, published_date_string) // date of source publication
		current_statement += fmt.Sprintf(`S813	+%s/11`, retrived_date) // retrieved date
		current_statement += "\n" // end of statement
		current_statement += fmt.Sprintf(`S813	+%s/11`, retrived_date)          // retrieved date
		current_statement += "\n"                                               // end of statement
		QSV1 += current_statement
	}
	return

M generators_test.go => generators_test.go +10 -0
@@ 19,6 19,7 @@ package quick_statement_generator_for_software_version_identifier_test
import (
	"fmt"
	"testing"
	"time"
	"log"

	QSGSVI "gitlab.com/JacksonChen666/quick_statement_generator_for_software_version_identifier"


@@ 40,3 41,12 @@ func TestRemoveDuplicates(t *testing.T) {
	}
	fmt.Println(missingDataToAdd)
}

func TestReleaseTypes(t *testing.T) {
	log.Println("testing release types and stuff")
	toMaybeAdd := make([]QSGSVI.SourceInfo, 0, 1)
	toMaybeAdd = append(toMaybeAdd, QSGSVI.SourceInfo{Name: "1.1.1-rc.1", URL: "https://example.com", PublishedAt: "2022-02-22T00:00:00Z"})
	retrivedDate := time.Now()
	generated := QSGSVI.GenerateQSV1FromData("none", &toMaybeAdd, &retrivedDate, false)
	fmt.Println(generated)
}