forked from ALHP/ALHP.GO
Hash each PKGBUILD and compare before parsing, fixes #25
This will speed things up significantly. See #25 for more information and discussion.
This commit is contained in:
@@ -29,6 +29,8 @@ const (
|
||||
FieldBuildDuration = "build_duration"
|
||||
// FieldUpdated holds the string denoting the updated field in the database.
|
||||
FieldUpdated = "updated"
|
||||
// FieldHash holds the string denoting the hash field in the database.
|
||||
FieldHash = "hash"
|
||||
// Table holds the table name of the dbpackage in the database.
|
||||
Table = "db_packages"
|
||||
)
|
||||
@@ -47,6 +49,7 @@ var Columns = []string{
|
||||
FieldBuildTime,
|
||||
FieldBuildDuration,
|
||||
FieldUpdated,
|
||||
FieldHash,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
|
@@ -162,6 +162,13 @@ func Updated(v time.Time) predicate.DbPackage {
|
||||
})
|
||||
}
|
||||
|
||||
// Hash applies equality check predicate on the "hash" field. It's identical to HashEQ.
|
||||
func Hash(v string) predicate.DbPackage {
|
||||
return predicate.DbPackage(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldHash), v))
|
||||
})
|
||||
}
|
||||
|
||||
// PkgbaseEQ applies the EQ predicate on the "pkgbase" field.
|
||||
func PkgbaseEQ(v string) predicate.DbPackage {
|
||||
return predicate.DbPackage(func(s *sql.Selector) {
|
||||
@@ -1230,6 +1237,131 @@ func UpdatedNotNil() predicate.DbPackage {
|
||||
})
|
||||
}
|
||||
|
||||
// HashEQ applies the EQ predicate on the "hash" field.
|
||||
func HashEQ(v string) predicate.DbPackage {
|
||||
return predicate.DbPackage(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldHash), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HashNEQ applies the NEQ predicate on the "hash" field.
|
||||
func HashNEQ(v string) predicate.DbPackage {
|
||||
return predicate.DbPackage(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldHash), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HashIn applies the In predicate on the "hash" field.
|
||||
func HashIn(vs ...string) predicate.DbPackage {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.DbPackage(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldHash), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// HashNotIn applies the NotIn predicate on the "hash" field.
|
||||
func HashNotIn(vs ...string) predicate.DbPackage {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.DbPackage(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldHash), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// HashGT applies the GT predicate on the "hash" field.
|
||||
func HashGT(v string) predicate.DbPackage {
|
||||
return predicate.DbPackage(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldHash), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HashGTE applies the GTE predicate on the "hash" field.
|
||||
func HashGTE(v string) predicate.DbPackage {
|
||||
return predicate.DbPackage(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldHash), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HashLT applies the LT predicate on the "hash" field.
|
||||
func HashLT(v string) predicate.DbPackage {
|
||||
return predicate.DbPackage(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldHash), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HashLTE applies the LTE predicate on the "hash" field.
|
||||
func HashLTE(v string) predicate.DbPackage {
|
||||
return predicate.DbPackage(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldHash), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HashContains applies the Contains predicate on the "hash" field.
|
||||
func HashContains(v string) predicate.DbPackage {
|
||||
return predicate.DbPackage(func(s *sql.Selector) {
|
||||
s.Where(sql.Contains(s.C(FieldHash), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HashHasPrefix applies the HasPrefix predicate on the "hash" field.
|
||||
func HashHasPrefix(v string) predicate.DbPackage {
|
||||
return predicate.DbPackage(func(s *sql.Selector) {
|
||||
s.Where(sql.HasPrefix(s.C(FieldHash), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HashHasSuffix applies the HasSuffix predicate on the "hash" field.
|
||||
func HashHasSuffix(v string) predicate.DbPackage {
|
||||
return predicate.DbPackage(func(s *sql.Selector) {
|
||||
s.Where(sql.HasSuffix(s.C(FieldHash), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HashIsNil applies the IsNil predicate on the "hash" field.
|
||||
func HashIsNil() predicate.DbPackage {
|
||||
return predicate.DbPackage(func(s *sql.Selector) {
|
||||
s.Where(sql.IsNull(s.C(FieldHash)))
|
||||
})
|
||||
}
|
||||
|
||||
// HashNotNil applies the NotNil predicate on the "hash" field.
|
||||
func HashNotNil() predicate.DbPackage {
|
||||
return predicate.DbPackage(func(s *sql.Selector) {
|
||||
s.Where(sql.NotNull(s.C(FieldHash)))
|
||||
})
|
||||
}
|
||||
|
||||
// HashEqualFold applies the EqualFold predicate on the "hash" field.
|
||||
func HashEqualFold(v string) predicate.DbPackage {
|
||||
return predicate.DbPackage(func(s *sql.Selector) {
|
||||
s.Where(sql.EqualFold(s.C(FieldHash), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HashContainsFold applies the ContainsFold predicate on the "hash" field.
|
||||
func HashContainsFold(v string) predicate.DbPackage {
|
||||
return predicate.DbPackage(func(s *sql.Selector) {
|
||||
s.Where(sql.ContainsFold(s.C(FieldHash), v))
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.DbPackage) predicate.DbPackage {
|
||||
return predicate.DbPackage(func(s *sql.Selector) {
|
||||
|
Reference in New Issue
Block a user